OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ | 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ |
12 #define WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ | 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ |
13 | 13 |
14 #pragma message("WARNING: common_video/include is DEPRECATED; use common_video/i nclude") | 14 #pragma message("WARNING: common_video/include is DEPRECATED; use common_video/i nclude") |
15 | 15 |
16 #include "webrtc/base/scoped_ptr.h" | 16 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/base/thread_annotations.h" | 17 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/common_video/video_render_frames.h" | 18 #include "webrtc/common_video/video_render_frames.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 class CriticalSectionWrapper; | 21 class CriticalSectionWrapper; |
22 class EventTimerWrapper; | 22 class EventTimerWrapper; |
23 class ThreadWrapper; | 23 class ThreadWrapper; |
24 class VideoRenderer; | |
24 | 25 |
25 class VideoRenderCallback { | 26 class VideoRenderCallback { |
26 public: | 27 public: |
27 virtual int32_t RenderFrame(const uint32_t streamId, | 28 virtual int32_t RenderFrame(const uint32_t streamId, |
28 const VideoFrame& videoFrame) = 0; | 29 const VideoFrame& videoFrame) = 0; |
29 | 30 |
30 protected: | 31 protected: |
31 virtual ~VideoRenderCallback() {} | 32 virtual ~VideoRenderCallback() {} |
32 }; | 33 }; |
33 | 34 |
34 class IncomingVideoStream : public VideoRenderCallback { | 35 class IncomingVideoStream : public VideoRenderCallback { |
35 public: | 36 public: |
36 explicit IncomingVideoStream(uint32_t stream_id); | 37 explicit IncomingVideoStream(uint32_t stream_id); |
38 IncomingVideoStream(uint32_t stream_id, VideoRenderer* renderer); | |
37 ~IncomingVideoStream(); | 39 ~IncomingVideoStream(); |
38 | 40 |
39 // Get callback to deliver frames to the module. | 41 // Get callback to deliver frames to the module. |
40 VideoRenderCallback* ModuleCallback(); | 42 VideoRenderCallback* ModuleCallback(); |
41 virtual int32_t RenderFrame(const uint32_t stream_id, | 43 virtual int32_t RenderFrame(const uint32_t stream_id, |
42 const VideoFrame& video_frame); | 44 const VideoFrame& video_frame); |
43 | 45 |
44 // Set callback to the platform dependent code. | 46 // Set callback to the platform dependent code. |
45 void SetRenderCallback(VideoRenderCallback* render_callback); | 47 void SetRenderCallback(VideoRenderCallback* render_callback); |
46 | 48 |
(...skipping 21 matching lines...) Expand all Loading... | |
68 protected: | 70 protected: |
69 static bool IncomingVideoStreamThreadFun(void* obj); | 71 static bool IncomingVideoStreamThreadFun(void* obj); |
70 bool IncomingVideoStreamProcess(); | 72 bool IncomingVideoStreamProcess(); |
71 | 73 |
72 private: | 74 private: |
73 enum { kEventStartupTimeMs = 10 }; | 75 enum { kEventStartupTimeMs = 10 }; |
74 enum { kEventMaxWaitTimeMs = 100 }; | 76 enum { kEventMaxWaitTimeMs = 100 }; |
75 enum { kFrameRatePeriodMs = 1000 }; | 77 enum { kFrameRatePeriodMs = 1000 }; |
76 | 78 |
77 uint32_t const stream_id_; | 79 uint32_t const stream_id_; |
80 VideoRenderer* const renderer_; | |
pbos-webrtc
2015/11/23 14:28:05
this should be a const bool instead of a pointer t
qiangchen
2015/11/24 00:21:05
Done.
| |
78 // Critsects in allowed to enter order. | 81 // Critsects in allowed to enter order. |
79 const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_; | 82 const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_; |
80 const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_; | 83 const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_; |
81 const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_; | 84 const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_; |
82 rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_ | 85 rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_ |
83 GUARDED_BY(thread_critsect_); | 86 GUARDED_BY(thread_critsect_); |
84 rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_; | 87 rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_; |
85 | 88 |
86 bool running_ GUARDED_BY(stream_critsect_); | 89 bool running_ GUARDED_BY(stream_critsect_); |
87 VideoRenderCallback* external_callback_ GUARDED_BY(thread_critsect_); | 90 VideoRenderCallback* external_callback_ GUARDED_BY(thread_critsect_); |
88 VideoRenderCallback* render_callback_ GUARDED_BY(thread_critsect_); | 91 VideoRenderCallback* render_callback_ GUARDED_BY(thread_critsect_); |
89 const rtc::scoped_ptr<VideoRenderFrames> render_buffers_ | 92 const rtc::scoped_ptr<VideoRenderFrames> render_buffers_ |
90 GUARDED_BY(buffer_critsect_); | 93 GUARDED_BY(buffer_critsect_); |
91 | 94 |
92 uint32_t incoming_rate_ GUARDED_BY(stream_critsect_); | 95 uint32_t incoming_rate_ GUARDED_BY(stream_critsect_); |
93 int64_t last_rate_calculation_time_ms_ GUARDED_BY(stream_critsect_); | 96 int64_t last_rate_calculation_time_ms_ GUARDED_BY(stream_critsect_); |
94 uint16_t num_frames_since_last_calculation_ GUARDED_BY(stream_critsect_); | 97 uint16_t num_frames_since_last_calculation_ GUARDED_BY(stream_critsect_); |
95 int64_t last_render_time_ms_ GUARDED_BY(thread_critsect_); | 98 int64_t last_render_time_ms_ GUARDED_BY(thread_critsect_); |
96 VideoFrame temp_frame_ GUARDED_BY(thread_critsect_); | 99 VideoFrame temp_frame_ GUARDED_BY(thread_critsect_); |
97 VideoFrame start_image_ GUARDED_BY(thread_critsect_); | 100 VideoFrame start_image_ GUARDED_BY(thread_critsect_); |
98 VideoFrame timeout_image_ GUARDED_BY(thread_critsect_); | 101 VideoFrame timeout_image_ GUARDED_BY(thread_critsect_); |
99 uint32_t timeout_time_ GUARDED_BY(thread_critsect_); | 102 uint32_t timeout_time_ GUARDED_BY(thread_critsect_); |
100 }; | 103 }; |
101 | 104 |
102 } // namespace webrtc | 105 } // namespace webrtc |
103 | 106 |
104 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ | 107 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ |
OLD | NEW |