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_INTERFACE_INCOMING_VIDEO_STREAM_H_ | 11 #ifndef WEBRTC_COMMON_VIDEO_INTERFACE_INCOMING_VIDEO_STREAM_H_ |
12 #define WEBRTC_COMMON_VIDEO_INTERFACE_INCOMING_VIDEO_STREAM_H_ | 12 #define WEBRTC_COMMON_VIDEO_INTERFACE_INCOMING_VIDEO_STREAM_H_ |
13 | 13 |
14 #include "webrtc/base/scoped_ptr.h" | 14 #include "webrtc/base/scoped_ptr.h" |
15 #include "webrtc/base/thread_annotations.h" | 15 #include "webrtc/base/thread_annotations.h" |
16 #include "webrtc/common_video/video_render_frames.h" | 16 #include "webrtc/video_frame.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 class CriticalSectionWrapper; | 19 class CriticalSectionWrapper; |
20 class EventTimerWrapper; | 20 class EventTimerWrapper; |
21 class ThreadWrapper; | 21 class ThreadWrapper; |
22 | 22 |
23 class VideoRenderCallback { | 23 class VideoRenderCallback { |
24 public: | 24 public: |
25 virtual int32_t RenderFrame(const uint32_t streamId, | 25 virtual int32_t RenderFrame(const uint32_t streamId, |
26 const VideoFrame& videoFrame) = 0; | 26 const VideoFrame& videoFrame) = 0; |
(...skipping 29 matching lines...) Expand all Loading... |
56 uint32_t StreamId() const; | 56 uint32_t StreamId() const; |
57 uint32_t IncomingRate() const; | 57 uint32_t IncomingRate() const; |
58 | 58 |
59 int32_t SetStartImage(const VideoFrame& video_frame); | 59 int32_t SetStartImage(const VideoFrame& video_frame); |
60 | 60 |
61 int32_t SetTimeoutImage(const VideoFrame& video_frame, | 61 int32_t SetTimeoutImage(const VideoFrame& video_frame, |
62 const uint32_t timeout); | 62 const uint32_t timeout); |
63 | 63 |
64 int32_t SetExpectedRenderDelay(int32_t delay_ms); | 64 int32_t SetExpectedRenderDelay(int32_t delay_ms); |
65 | 65 |
66 protected: | |
67 static bool IncomingVideoStreamThreadFun(void* obj); | |
68 bool IncomingVideoStreamProcess(); | |
69 | |
70 private: | 66 private: |
71 enum { kEventStartupTimeMs = 10 }; | 67 enum { kEventStartupTimeMs = 10 }; |
72 enum { kEventMaxWaitTimeMs = 100 }; | 68 enum { kEventMaxWaitTimeMs = 100 }; |
73 enum { kFrameRatePeriodMs = 1000 }; | 69 enum { kFrameRatePeriodMs = 1000 }; |
74 | 70 |
75 uint32_t const stream_id_; | 71 uint32_t const stream_id_; |
76 // Critsects in allowed to enter order. | 72 // Critsects in allowed to enter order. |
77 const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_; | 73 const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_; |
78 const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_; | 74 const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_; |
79 const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_; | |
80 rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_ | |
81 GUARDED_BY(thread_critsect_); | |
82 rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_; | |
83 | 75 |
84 bool running_ GUARDED_BY(stream_critsect_); | 76 bool running_ GUARDED_BY(stream_critsect_); |
85 VideoRenderCallback* external_callback_ GUARDED_BY(thread_critsect_); | 77 VideoRenderCallback* external_callback_ GUARDED_BY(thread_critsect_); |
86 VideoRenderCallback* render_callback_ GUARDED_BY(thread_critsect_); | 78 VideoRenderCallback* render_callback_ GUARDED_BY(thread_critsect_); |
87 const rtc::scoped_ptr<VideoRenderFrames> render_buffers_ | |
88 GUARDED_BY(buffer_critsect_); | |
89 | 79 |
90 uint32_t incoming_rate_ GUARDED_BY(stream_critsect_); | 80 uint32_t incoming_rate_ GUARDED_BY(stream_critsect_); |
91 int64_t last_rate_calculation_time_ms_ GUARDED_BY(stream_critsect_); | 81 int64_t last_rate_calculation_time_ms_ GUARDED_BY(stream_critsect_); |
92 uint16_t num_frames_since_last_calculation_ GUARDED_BY(stream_critsect_); | 82 uint16_t num_frames_since_last_calculation_ GUARDED_BY(stream_critsect_); |
93 int64_t last_render_time_ms_ GUARDED_BY(thread_critsect_); | 83 int64_t last_render_time_ms_ GUARDED_BY(thread_critsect_); |
94 VideoFrame temp_frame_ GUARDED_BY(thread_critsect_); | 84 VideoFrame temp_frame_ GUARDED_BY(thread_critsect_); |
95 VideoFrame start_image_ GUARDED_BY(thread_critsect_); | 85 VideoFrame start_image_ GUARDED_BY(thread_critsect_); |
96 VideoFrame timeout_image_ GUARDED_BY(thread_critsect_); | 86 VideoFrame timeout_image_ GUARDED_BY(thread_critsect_); |
97 uint32_t timeout_time_ GUARDED_BY(thread_critsect_); | 87 uint32_t timeout_time_ GUARDED_BY(thread_critsect_); |
98 }; | 88 }; |
99 | 89 |
100 } // namespace webrtc | 90 } // namespace webrtc |
101 | 91 |
102 #endif // WEBRTC_COMMON_VIDEO_INTERFACE_INCOMING_VIDEO_STREAM_H_ | 92 #endif // WEBRTC_COMMON_VIDEO_INTERFACE_INCOMING_VIDEO_STREAM_H_ |
OLD | NEW |