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


    medialibstagefrightwifi-displaysource

    编码那一块

    pizzaframeworksavmedialibstagefrightwifi-displaysourceConverter.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;

    pizzaframeworksavmedialibstagefrightwifi-displaysourceConverter.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 //}
           
    }

    pizzaframeworksavmedialibstagefrightwifi-displaysourceMediaPuller.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());
                }

    case kWhatPull:
    {
        int32_t generation;
        CHECK(msg->findInt32("generation", &generation));

        if (generation != mPullGeneration) {
            break;
        }

        MediaBuffer *mbuf;
        status_t err = mSource->read(&mbuf);

        if (mPaused) {
            if (err == OK) {
                mbuf->release();
                mbuf = NULL;
            }

            schedulePull();
            break;
        }

    pizzaframeworksavmedialibstagefrightwifi-displaysourcePlaybackSession.h

      负责管理wifidisplay当中的RTP/RTCP的网络连接

    PlaybackSession(
            const sp<ANetworkSession> &netSession,
            const sp<AMessage> &notify,
            const struct in_addr &interfaceAddr,
            const sp<IHDCP> &hdcp,
            int      width=0,
            int          height=0,
            bool         isRecordingScreen=false,
            WifiDisplaySource *wifiDisplaySource=NULL);

    PlaybackSession(
            const sp<ANetworkSession> &netSession,
            const sp<AMessage> &notify,
            const struct in_addr &interfaceAddr,
            const sp<IHDCP> &hdcp,
            int   width=0,
            int   height=0,
            WifiDisplaySource *wifiDisplaySource=NULL);

    status_t initEx(
              const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
              Sender::TransportMode transportMode,
              bool usePCMAudio, char *outfile);

    bool mIsRecordingScreen;
    WifiDisplaySource *mWifiDisplaySource;

    pizzaframeworksavmedialibstagefrightwifi-displaysourceSender.h

    #include "WifiDisplaySource.h"

    struct WifiDisplaySource;

    Sender(const sp<ANetworkSession> &netSession, const sp<AMessage> &notify, char *outfile, WifiDisplaySource *wifiDisplaySource);

    bool mIsRecordingScreen;
    WifiDisplaySource *mWifiDisplaySource;

    //#if LOG_TRANSPORT_STREAM
        FILE *mLogFile;
    //#endif
         char mOutFile[1024];
        char mRecBuf[1024 * 10];

    status_t sendTsPacket(int32_t sessionID, const void *data, size_t size);

    pizzaframeworksavmedialibstagefrightwifi-displaysourceTSPacketizer.cpp

      转换成TS数据流

    pizzaframeworksavmedialibstagefrightwifi-displaysourceWifiDisplaySource.h

      wifidisplay的总管理

    status_t startRecord(const char *iface);

    status_t record(char *data, int len);

    enum {
        kWhatStart,
        kWhatRTSPNotify,
        kWhatStop,
        kWhatPause,
        kWhatResume,
        kWhatReapDeadClients,
        kWhatPlaybackSessionNotify,
        kWhatKeepAlive,
        kWhatHDCPNotify,
        kWhatFinishStop2,
        kWhatTeardownTriggerTimedOut,
        kWhatStartRecord,
        kWhatSetupRecord,
        kWhatRecord,
        kWhatStopRecord,

    };

        status_t onSetupRequestEx(char *outfile);
        status_t onPlayRequest(
                int32_t sessionID,
                int32_t cseq,
                const sp<ParsedMessage> &data);
        status_t onPlayRequestEx();
        status_t onPauseRequest(
                int32_t sessionID,
                int32_t cseq,
                const sp<ParsedMessage> &data);
       status_t onPauseRequestEx();
        status_t onTeardownRequest(
                int32_t sessionID,
                int32_t cseq,
                const sp<ParsedMessage> &data);

        status_t onTeardownRequestEx();
        void setOutputFile(const char *filename);

    pizzaframeworksavmedialibstagefrightwifi-displayANetworkSession.cpp

      将转发到

    status_t sendTsPacket(const void *data, ssize_t size);

    void     setRtpSink(RTPSink* rtpsink);

    ANetworkSession *mNetworkSession;
        sp<RTPSink> mRTPSink;

  • 相关阅读:
    box-shadow 用法总结
    CSS绘制三角形
    js实现限制容器中字符个数
    解决 IE 或者兼容模式不支持 document.getElementsByClassName() 的方法
    JavaScript获取浏览器高度和宽度值(documentElement,clientHeight,offsetHeight,scrollHeight,scrollTop,offsetParent,offsetY,innerHeight)
    appium-python-api中文文档
    通过adb获取应用的Activity堆栈信息
    小米手机连接adb只显示List of devices attached
    关于如何等待一个元素的出现而不用一些笨拙粗暴的time.sleep()方法
    Appium环境搭建
  • 原文地址:https://www.cnblogs.com/pengxinglove/p/5551156.html
Copyright © 2020-2023  润新知