android4.2 WifiDisplay远程显示修改为保存文件

Posted pengxinglove

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android4.2 WifiDisplay远程显示修改为保存文件相关的知识,希望对你有一定的参考价值。

media\libstagefright\wifi-display\source\

编码那一块

\pizza\frameworks\av\media\libstagefright\wifi-display\source\Converter.h

// Utility class that receives media access units and converts them into
// media access unit of a different format.
// Right now this‘ll convert raw video into H.264 and raw audio into AAC.
struct Converter : public AHandler {
    Converter(
            const sp<AMessage> &notify,
            const sp<ALooper> &codecLooper,
            const sp<AMessage> &format,
            bool usePCMAudio,
            bool isRecordingScreen);

bool mIsRecordingScreen;

 

pizza\frameworks\av\media\libstagefright\wifi-display\source\Converter.cpp

 

 

Converter::Converter(
        const sp<AMessage> &notify,
        const sp<ALooper> &codecLooper,
        const sp<AMessage> &format,
        bool usePCMAudio,
        bool isRecordingScreen)
    : mInitCheck(NO_INIT),
      mNotify(notify),
      mCodecLooper(codecLooper),
      mInputFormat(format),
      mIsVideo(false),
      mIsPCMAudio(usePCMAudio),
      mNeedToManuallyPrependSPSPPS(false),
      mDoMoreWorkPending(false)
#if ENABLE_SILENCE_DETECTION
      ,mFirstSilentFrameUs(-1ll)
      ,mInSilentMode(false)
#endif
    {
    AString mime;
    CHECK(mInputFormat->findString("mime", &mime));
    mIsRecordingScreen = isRecordingScreen;
    if (!strncasecmp("video/", mime.c_str(), 6)) {
        mIsVideo = true;
    }

    CHECK(!usePCMAudio || !mIsVideo);

    mInitCheck = initEncoder();

    if (mInitCheck != OK) {
        if (mEncoder != NULL) {
            mEncoder->release();
            mEncoder.clear();
        }
    }
}

void Converter::shutdownAsync() {
    ALOGV("shutdown");
    if(!mIsRecordingScreen)
    {
         (new AMessage(kWhatShutdown, id()))->post();
         return;
    }

#if 1 //{     
    if (mEncoder != NULL) {
          mEncoder->release();
          mEncoder.clear();
    }
#endif //}
       
}

pizza\frameworks\av\media\libstagefright\wifi-display\source\MediaPuller.cpp

void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatStart:
        {
            status_t err;
            if (mIsAudio) {
                // This atrocity causes Audiosource to deliver absolute
                // systemTime() based timestamps (off by 1 us).
                sp<MetaData> params = new MetaData;
                params->setInt64(kKeyTime, 1ll);
                err = mSource->start(params.get());
            } else {
                sp<MetaData> params = new MetaData;

// 是不是将关键帧设置了只有三个
                 params->setInt32(kKeyNumBuffers,3 );
                err = mSource->start(params.get());
            }

pizza\frameworks\av\media\libstagefright\wifi-display\source\PlaybackSession.h

以上是关于android4.2 WifiDisplay远程显示修改为保存文件的主要内容,如果未能解决你的问题,请参考以下文章

android 4.2上面实现录制系统内置声音remote submix

Android下WiFiDisplay功能探究

Android下WiFiDisplay功能探究

Android WifiDisplay分析二:Wifi display连接过程

Android WifiDisplay分析三:RTSP交互以及数据传输

wifi display代码 分析