Home | History | Annotate | Download | only in video_render
      1 /*
      2  *  Copyright (c) 2011 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_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
     12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
     13 
     14 #include <map>
     15 
     16 #include "webrtc/engine_configurations.h"
     17 #include "webrtc/modules/video_render/video_render.h"
     18 
     19 namespace webrtc {
     20 class CriticalSectionWrapper;
     21 class IncomingVideoStream;
     22 class IVideoRender;
     23 
     24 // Class definitions
     25 class ModuleVideoRenderImpl: public VideoRender
     26 {
     27 public:
     28     /*
     29      *   VideoRenderer constructor/destructor
     30      */
     31     ModuleVideoRenderImpl(const int32_t id,
     32                           const VideoRenderType videoRenderType,
     33                           void* window, const bool fullscreen);
     34 
     35     virtual ~ModuleVideoRenderImpl();
     36 
     37     virtual int64_t TimeUntilNextProcess();
     38     virtual int32_t Process();
     39 
     40     /*
     41      *   Returns the render window
     42      */
     43     virtual void* Window();
     44 
     45     /*
     46      *   Change render window
     47      */
     48     virtual int32_t ChangeWindow(void* window);
     49 
     50     /*
     51      *   Returns module id
     52      */
     53     int32_t Id();
     54 
     55     /**************************************************************************
     56      *
     57      *   Incoming Streams
     58      *
     59      ***************************************************************************/
     60 
     61     /*
     62      *   Add incoming render stream
     63      */
     64     virtual VideoRenderCallback
     65             * AddIncomingRenderStream(const uint32_t streamId,
     66                                       const uint32_t zOrder,
     67                                       const float left, const float top,
     68                                       const float right, const float bottom);
     69     /*
     70      *   Delete incoming render stream
     71      */
     72     virtual int32_t
     73             DeleteIncomingRenderStream(const uint32_t streamId);
     74 
     75     /*
     76      *   Add incoming render callback, used for external rendering
     77      */
     78     virtual int32_t
     79             AddExternalRenderCallback(const uint32_t streamId,
     80                                       VideoRenderCallback* renderObject);
     81 
     82     /*
     83      *   Get the porperties for an incoming render stream
     84      */
     85     virtual int32_t
     86             GetIncomingRenderStreamProperties(const uint32_t streamId,
     87                                               uint32_t& zOrder,
     88                                               float& left, float& top,
     89                                               float& right, float& bottom) const;
     90     /*
     91      *   Incoming frame rate for the specified stream.
     92      */
     93     virtual uint32_t GetIncomingFrameRate(const uint32_t streamId);
     94 
     95     /*
     96      *   Returns the number of incoming streams added to this render module
     97      */
     98     virtual uint32_t GetNumIncomingRenderStreams() const;
     99 
    100     /*
    101      *   Returns true if this render module has the streamId added, false otherwise.
    102      */
    103     virtual bool HasIncomingRenderStream(const uint32_t streamId) const;
    104 
    105     /*
    106      *
    107      */
    108     virtual int32_t
    109             RegisterRawFrameCallback(const uint32_t streamId,
    110                                      VideoRenderCallback* callbackObj);
    111 
    112     virtual int32_t SetExpectedRenderDelay(uint32_t stream_id,
    113                                            int32_t delay_ms);
    114 
    115     /**************************************************************************
    116      *
    117      *   Start/Stop
    118      *
    119      ***************************************************************************/
    120 
    121     /*
    122      *   Starts rendering the specified stream
    123      */
    124     virtual int32_t StartRender(const uint32_t streamId);
    125 
    126     /*
    127      *   Stops the renderer
    128      */
    129     virtual int32_t StopRender(const uint32_t streamId);
    130 
    131     /*
    132      *   Sets the renderer in start state, no streams removed.
    133      */
    134     virtual int32_t ResetRender();
    135 
    136     /**************************************************************************
    137      *
    138      *   Properties
    139      *
    140      ***************************************************************************/
    141 
    142     /*
    143      *   Returns the prefered render video type
    144      */
    145     virtual RawVideoType PreferredVideoType() const;
    146 
    147     /*
    148      *   Returns true if the renderer is in fullscreen mode, otherwise false.
    149      */
    150     virtual bool IsFullScreen();
    151 
    152     /*
    153      *   Gets screen resolution in pixels
    154      */
    155     virtual int32_t
    156             GetScreenResolution(uint32_t& screenWidth,
    157                                 uint32_t& screenHeight) const;
    158 
    159     /*
    160      *   Get the actual render rate for this stream. I.e rendered frame rate,
    161      *   not frames delivered to the renderer.
    162      */
    163     virtual uint32_t RenderFrameRate(const uint32_t streamId);
    164 
    165     /*
    166      *   Set cropping of incoming stream
    167      */
    168     virtual int32_t SetStreamCropping(const uint32_t streamId,
    169                                       const float left, const float top,
    170                                       const float right, const float bottom);
    171 
    172     virtual int32_t ConfigureRenderer(const uint32_t streamId,
    173                                       const unsigned int zOrder,
    174                                       const float left, const float top,
    175                                       const float right, const float bottom);
    176 
    177     virtual int32_t SetTransparentBackground(const bool enable);
    178 
    179     virtual int32_t FullScreenRender(void* window, const bool enable);
    180 
    181     virtual int32_t SetBitmap(const void* bitMap,
    182                               const uint8_t pictureId,
    183                               const void* colorKey,
    184                               const float left, const float top,
    185                               const float right, const float bottom);
    186 
    187     virtual int32_t SetText(const uint8_t textId,
    188                             const uint8_t* text,
    189                             const int32_t textLength,
    190                             const uint32_t textColorRef,
    191                             const uint32_t backgroundColorRef,
    192                             const float left, const float top,
    193                             const float right, const float bottom);
    194 
    195     virtual int32_t SetStartImage(const uint32_t streamId,
    196                                   const VideoFrame& videoFrame);
    197 
    198     virtual int32_t SetTimeoutImage(const uint32_t streamId,
    199                                     const VideoFrame& videoFrame,
    200                                     const uint32_t timeout);
    201 
    202 private:
    203     int32_t _id;
    204     CriticalSectionWrapper& _moduleCrit;
    205     void* _ptrWindow;
    206     bool _fullScreen;
    207 
    208     IVideoRender* _ptrRenderer;
    209     typedef std::map<uint32_t, IncomingVideoStream*> IncomingVideoStreamMap;
    210     IncomingVideoStreamMap _streamRenderMap;
    211 };
    212 
    213 }  // namespace webrtc
    214 
    215 #endif  // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
    216