OLD | NEW |
(Empty) | |
| 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_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_IMP
L_H_ |
| 12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_IMP
L_H_ |
| 13 |
| 14 #include <jni.h> |
| 15 |
| 16 #include <map> |
| 17 #include <memory> |
| 18 |
| 19 #include "webrtc/base/platform_thread.h" |
| 20 #include "webrtc/modules/video_render/i_video_render.h" |
| 21 |
| 22 |
| 23 namespace webrtc { |
| 24 |
| 25 //#define ANDROID_LOG |
| 26 |
| 27 class CriticalSectionWrapper; |
| 28 class EventWrapper; |
| 29 |
| 30 // The object a module user uses to send new frames to the java renderer |
| 31 // Base class for android render streams. |
| 32 |
| 33 class AndroidStream : public VideoRenderCallback { |
| 34 public: |
| 35 // DeliverFrame is called from a thread connected to the Java VM. |
| 36 // Used for Delivering frame for rendering. |
| 37 virtual void DeliverFrame(JNIEnv* jniEnv)=0; |
| 38 |
| 39 virtual ~AndroidStream() {}; |
| 40 }; |
| 41 |
| 42 class VideoRenderAndroid: IVideoRender { |
| 43 public: |
| 44 VideoRenderAndroid(const int32_t id, |
| 45 const VideoRenderType videoRenderType, |
| 46 void* window, |
| 47 const bool fullscreen); |
| 48 |
| 49 virtual ~VideoRenderAndroid(); |
| 50 |
| 51 virtual int32_t Init()=0; |
| 52 |
| 53 virtual int32_t ChangeWindow(void* window); |
| 54 |
| 55 virtual VideoRenderCallback* AddIncomingRenderStream( |
| 56 const uint32_t streamId, |
| 57 const uint32_t zOrder, |
| 58 const float left, const float top, |
| 59 const float right, const float bottom); |
| 60 |
| 61 virtual int32_t DeleteIncomingRenderStream( |
| 62 const uint32_t streamId); |
| 63 |
| 64 virtual int32_t GetIncomingRenderStreamProperties( |
| 65 const uint32_t streamId, |
| 66 uint32_t& zOrder, |
| 67 float& left, float& top, |
| 68 float& right, float& bottom) const; |
| 69 |
| 70 virtual int32_t StartRender(); |
| 71 |
| 72 virtual int32_t StopRender(); |
| 73 |
| 74 virtual void ReDraw(); |
| 75 |
| 76 // Properties |
| 77 |
| 78 virtual VideoRenderType RenderType(); |
| 79 |
| 80 virtual RawVideoType PerferedVideoType(); |
| 81 |
| 82 virtual bool FullScreen(); |
| 83 |
| 84 virtual int32_t GetGraphicsMemory( |
| 85 uint64_t& totalGraphicsMemory, |
| 86 uint64_t& availableGraphicsMemory) const; |
| 87 |
| 88 virtual int32_t GetScreenResolution( |
| 89 uint32_t& screenWidth, |
| 90 uint32_t& screenHeight) const; |
| 91 |
| 92 virtual uint32_t RenderFrameRate(const uint32_t streamId); |
| 93 |
| 94 virtual int32_t SetStreamCropping(const uint32_t streamId, |
| 95 const float left, const float top, |
| 96 const float right, const float bottom); |
| 97 |
| 98 virtual int32_t SetTransparentBackground(const bool enable); |
| 99 |
| 100 virtual int32_t ConfigureRenderer(const uint32_t streamId, |
| 101 const unsigned int zOrder, |
| 102 const float left, const float top, |
| 103 const float right, const float bottom); |
| 104 |
| 105 virtual int32_t SetText(const uint8_t textId, |
| 106 const uint8_t* text, |
| 107 const int32_t textLength, |
| 108 const uint32_t textColorRef, |
| 109 const uint32_t backgroundColorRef, |
| 110 const float left, const float top, |
| 111 const float rigth, const float bottom); |
| 112 |
| 113 virtual int32_t SetBitmap(const void* bitMap, |
| 114 const uint8_t pictureId, |
| 115 const void* colorKey, const float left, |
| 116 const float top, const float right, |
| 117 const float bottom); |
| 118 static JavaVM* g_jvm; |
| 119 |
| 120 protected: |
| 121 virtual AndroidStream* CreateAndroidRenderChannel( |
| 122 int32_t streamId, |
| 123 int32_t zOrder, |
| 124 const float left, |
| 125 const float top, |
| 126 const float right, |
| 127 const float bottom, |
| 128 VideoRenderAndroid& renderer) = 0; |
| 129 |
| 130 int32_t _id; |
| 131 CriticalSectionWrapper& _critSect; |
| 132 VideoRenderType _renderType; |
| 133 jobject _ptrWindow; |
| 134 |
| 135 private: |
| 136 static bool JavaRenderThreadFun(void* obj); |
| 137 bool JavaRenderThreadProcess(); |
| 138 |
| 139 // Map with streams to render. |
| 140 typedef std::map<int32_t, AndroidStream*> AndroidStreamMap; |
| 141 AndroidStreamMap _streamsMap; |
| 142 // True if the _javaRenderThread thread shall be detached from the JVM. |
| 143 bool _javaShutDownFlag; |
| 144 EventWrapper& _javaShutdownEvent; |
| 145 EventWrapper& _javaRenderEvent; |
| 146 int64_t _lastJavaRenderEvent; |
| 147 JNIEnv* _javaRenderJniEnv; // JNIEnv for the java render thread. |
| 148 // TODO(pbos): Remove unique_ptr and use the member directly. |
| 149 std::unique_ptr<rtc::PlatformThread> _javaRenderThread; |
| 150 }; |
| 151 |
| 152 } // namespace webrtc |
| 153 |
| 154 #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_
IMPL_H_ |
OLD | NEW |