Home | History | Annotate | Download | only in video_engine
      1 /*
      2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_
     12 #define WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_
     13 
     14 #include "webrtc/modules/video_render/include/video_render_defines.h"
     15 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
     16 #include "webrtc/video_engine/include/vie_render.h"
     17 #include "webrtc/video_engine/vie_frame_provider_base.h"
     18 
     19 namespace webrtc {
     20 
     21 class VideoRender;
     22 class VideoRenderCallback;
     23 class ViERenderManager;
     24 
     25 class ViEExternalRendererImpl : public VideoRenderCallback {
     26  public:
     27   ViEExternalRendererImpl();
     28   virtual ~ViEExternalRendererImpl() {}
     29 
     30   int SetViEExternalRenderer(ExternalRenderer* external_renderer,
     31                              RawVideoType video_input_format);
     32 
     33   // Implements VideoRenderCallback.
     34   virtual int32_t RenderFrame(const uint32_t stream_id,
     35                               I420VideoFrame& video_frame);
     36 
     37  private:
     38   void NotifyFrameSizeChange(const uint32_t stream_id,
     39                              I420VideoFrame& video_frame);
     40   ExternalRenderer* external_renderer_;
     41   RawVideoType external_renderer_format_;
     42   int external_renderer_width_;
     43   int external_renderer_height_;
     44   // Converted_frame_ in color format specified by render_format_.
     45   scoped_ptr<VideoFrame> converted_frame_;
     46 };
     47 
     48 class ViERenderer: public ViEFrameCallback {
     49  public:
     50   static ViERenderer* CreateViERenderer(const int32_t render_id,
     51                                         const int32_t engine_id,
     52                                         VideoRender& render_module,
     53                                         ViERenderManager& render_manager,
     54                                         const uint32_t z_order,
     55                                         const float left,
     56                                         const float top,
     57                                         const float right,
     58                                         const float bottom);
     59   ~ViERenderer(void);
     60 
     61   int32_t StartRender();
     62   int32_t StopRender();
     63 
     64   int32_t GetLastRenderedFrame(const int32_t renderID,
     65                                I420VideoFrame& video_frame);
     66 
     67   int SetExpectedRenderDelay(int render_delay);
     68 
     69   int32_t ConfigureRenderer(const unsigned int z_order,
     70                             const float left,
     71                             const float top,
     72                             const float right,
     73                             const float bottom);
     74 
     75   VideoRender& RenderModule();
     76 
     77   int32_t EnableMirroring(const int32_t render_id,
     78                           const bool enable,
     79                           const bool mirror_xaxis,
     80                           const bool mirror_yaxis);
     81 
     82   int32_t SetTimeoutImage(const I420VideoFrame& timeout_image,
     83                           const int32_t timeout_value);
     84   int32_t SetRenderStartImage(const I420VideoFrame& start_image);
     85   int32_t SetExternalRenderer(const int32_t render_id,
     86                               RawVideoType video_input_format,
     87                               ExternalRenderer* external_renderer);
     88 
     89   int32_t SetVideoRenderCallback(const int32_t render_id,
     90                                  VideoRenderCallback* callback);
     91 
     92  private:
     93   ViERenderer(const int32_t render_id, const int32_t engine_id,
     94                 VideoRender& render_module,
     95                 ViERenderManager& render_manager);
     96 
     97   int32_t Init(const uint32_t z_order,
     98                const float left,
     99                const float top,
    100                const float right,
    101                const float bottom);
    102 
    103   // Implement ViEFrameCallback
    104   virtual void DeliverFrame(int id,
    105                             I420VideoFrame* video_frame,
    106                             int num_csrcs = 0,
    107                             const uint32_t CSRC[kRtpCsrcSize] = NULL);
    108   virtual void DelayChanged(int id, int frame_delay);
    109   virtual int GetPreferedFrameSettings(int* width,
    110                                        int* height,
    111                                        int* frame_rate);
    112   virtual void ProviderDestroyed(int id);
    113 
    114   uint32_t render_id_;
    115   VideoRender& render_module_;
    116   ViERenderManager& render_manager_;
    117   VideoRenderCallback* render_callback_;
    118   ViEExternalRendererImpl* incoming_external_callback_;
    119 };
    120 
    121 }  // namespace webrtc
    122 
    123 #endif  // WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_
    124