webrtc视频引擎之video_render(视频渲染)介绍
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                webrtc视频引擎之video_render(视频渲染)介绍
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                ?此部分為webrtc視頻渲染顯示,代碼結構如下:
??
? 其實此部分代碼與《webrtc視頻引擎之vedio_capture_module介紹》的代碼結構一樣
? ? 1,圖中能夠直接看到的.h和.cc文件也是一個適配作用,用于根據系統平臺適配采用某部分進行視頻渲染;
? ? 2, android文件夾用于在android平臺渲染顯示視頻圖像;
? ? 3, IOS文件夾用于在IOS平臺渲染顯示視頻圖像;
 
? ??4, linux文件夾用于在linux平臺渲染顯示視頻圖像;
? ??5, mac文件夾用于在mac平臺渲染顯示視頻圖像;
? ??6,windows文件夾用于在windows平臺渲染顯示視頻圖像;
 
?render圖像顯示模塊的接口類:
? ?在調用該接口類創建實例對象的時候需要從構造函數傳入 相關的顯示參數, 如下:
const int32_t id, //本路顯示視頻的ID,用戶自定義,用于唯一區分本路視頻即可 const VideoRenderType videoRenderType, // 此定于如下枚舉<pre name="code" class="cpp">enum VideoRenderType {kRenderExternal = 0, // ExternalkRenderWindows = 1, // WindowskRenderCocoa = 2, // MackRenderCarbon = 3,kRenderiOS = 4, // iPhonekRenderAndroid = 5, // AndroidkRenderX11 = 6, // LinuxkRenderDefault };void* window, //用于顯示視頻的窗口對象指針 const bool fullscreen //是否需要全屏顯示ModuleVideoRenderImpl(const int32_t id, const VideoRenderType videoRenderType, void* window, const bool fullscreen);該接口還是StartRender 、StopRender等接口供外部調用控制視頻渲染 </pre><pre code_snippet_id="1842801" snippet_file_name="blog_20160821_7_7573210" name="code" class="cpp"> class ModuleVideoRenderImpl: public VideoRender { public:/** VideoRenderer constructor/destructor*/ModuleVideoRenderImpl(const int32_t id,const VideoRenderType videoRenderType,void* window, const bool fullscreen);virtual ~ModuleVideoRenderImpl();/** Change the unique identifier of this object*/virtual int32_t ChangeUniqueId(const int32_t id);virtual int32_t TimeUntilNextProcess();virtual int32_t Process();/** Returns the render window*/virtual void* Window();/** Change render window*/virtual int32_t ChangeWindow(void* window);/** Returns module id*/int32_t Id();/**************************************************************************** Incoming Streams****************************************************************************//** Add incoming render stream*/virtual VideoRenderCallback* AddIncomingRenderStream(const uint32_t streamId,const uint32_t zOrder,const float left, const float top,const float right, const float bottom);/** Delete incoming render stream*/virtual int32_tDeleteIncomingRenderStream(const uint32_t streamId);/** Add incoming render callback, used for external rendering*/virtual int32_tAddExternalRenderCallback(const uint32_t streamId,VideoRenderCallback* renderObject);/** Get the porperties for an incoming render stream*/virtual int32_tGetIncomingRenderStreamProperties(const uint32_t streamId,uint32_t& zOrder,float& left, float& top,float& right, float& bottom) const;/** Incoming frame rate for the specified stream.*/virtual uint32_t GetIncomingFrameRate(const uint32_t streamId);/** Returns the number of incoming streams added to this render module*/virtual uint32_t GetNumIncomingRenderStreams() const;/** Returns true if this render module has the streamId added, false otherwise.*/virtual bool HasIncomingRenderStream(const uint32_t streamId) const;/***/virtual int32_tRegisterRawFrameCallback(const uint32_t streamId,VideoRenderCallback* callbackObj);virtual int32_t GetLastRenderedFrame(const uint32_t streamId,I420VideoFrame &frame) const;virtual int32_t SetExpectedRenderDelay(uint32_t stream_id,int32_t delay_ms);/**************************************************************************** Start/Stop****************************************************************************//** Starts rendering the specified stream*/virtual int32_t <span style="color:#ff0000;">StartRende</span>r(const uint32_t streamId);/** Stops the renderer*/virtual int32_t <span style="color:#ff0000;">StopRender</span>(const uint32_t streamId);/** Sets the renderer in start state, no streams removed.*/virtual int32_t ResetRender();/**************************************************************************** Properties****************************************************************************//** Returns the prefered render video type*/virtual RawVideoType PreferredVideoType() const;/** Returns true if the renderer is in fullscreen mode, otherwise false.*/virtual bool IsFullScreen();/** Gets screen resolution in pixels*/virtual int32_tGetScreenResolution(uint32_t& screenWidth,uint32_t& screenHeight) const;/** Get the actual render rate for this stream. I.e rendered frame rate,* not frames delivered to the renderer.*/virtual uint32_t RenderFrameRate(const uint32_t streamId);/** Set cropping of incoming stream*/virtual int32_t SetStreamCropping(const uint32_t streamId,const float left, const float top,const float right, const float bottom);virtual int32_t ConfigureRenderer(const uint32_t streamId,const unsigned int zOrder,const float left, const float top,const float right, const float bottom);virtual int32_t SetTransparentBackground(const bool enable);virtual int32_t FullScreenRender(void* window, const bool enable);virtual int32_t SetBitmap(const void* bitMap,const uint8_t pictureId,const void* colorKey,const float left, const float top,const float right, const float bottom);virtual int32_t SetText(const uint8_t textId,const uint8_t* text,const int32_t textLength,const uint32_t textColorRef,const uint32_t backgroundColorRef,const float left, const float top,const float right, const float bottom);virtual int32_t SetStartImage(const uint32_t streamId,const I420VideoFrame& videoFrame);virtual int32_t SetTimeoutImage(const uint32_t streamId,const I420VideoFrame& videoFrame,const uint32_t timeout);virtual int32_t MirrorRenderStream(const int renderId,const bool enable,const bool mirrorXAxis,const bool mirrorYAxis);private:int32_t _id;CriticalSectionWrapper& _moduleCrit;void* _ptrWindow;bool _fullScreen;IVideoRender* _ptrRenderer;typedef std::map<uint32_t, IncomingVideoStream*> IncomingVideoStreamMap;IncomingVideoStreamMap _streamRenderMap; };
? 有興趣的同學朋友可以自行去研究每個設備是怎么顯示視頻, ?至于每個設備如何顯示視頻這個后面都單獨介紹,這里只做個整體的介紹。
總結
以上是生活随笔為你收集整理的webrtc视频引擎之video_render(视频渲染)介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: ChatGPT45个插件列表
 - 下一篇: windows网络编程 --网络聊天室(