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 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/base/platform_thread.h" | 17 #include "webrtc/base/platform_thread.h" |
18 #include "webrtc/base/task_queue.h" | |
19 #include "webrtc/base/thread_annotations.h" | 18 #include "webrtc/base/thread_annotations.h" |
20 #include "webrtc/base/thread_checker.h" | |
21 #include "webrtc/common_video/video_render_frames.h" | 19 #include "webrtc/common_video/video_render_frames.h" |
22 #include "webrtc/media/base/videosinkinterface.h" | 20 #include "webrtc/media/base/videosinkinterface.h" |
23 | 21 |
24 namespace webrtc { | 22 namespace webrtc { |
25 class EventTimerWrapper; | 23 class EventTimerWrapper; |
26 | 24 |
| 25 |
27 class IncomingVideoStream : public rtc::VideoSinkInterface<VideoFrame> { | 26 class IncomingVideoStream : public rtc::VideoSinkInterface<VideoFrame> { |
28 public: | 27 public: |
29 IncomingVideoStream(int32_t delay_ms, | 28 explicit IncomingVideoStream(bool disable_prerenderer_smoothing); |
30 rtc::VideoSinkInterface<VideoFrame>* callback); | 29 ~IncomingVideoStream(); |
31 ~IncomingVideoStream() override; | 30 |
| 31 // Overrides VideoSinkInterface |
| 32 void OnFrame(const VideoFrame& video_frame) override; |
| 33 |
| 34 // Callback for file recording, snapshot, ... |
| 35 void SetExternalCallback(rtc::VideoSinkInterface<VideoFrame>* render_object); |
| 36 |
| 37 // Start/Stop. |
| 38 int32_t Start(); |
| 39 int32_t Stop(); |
| 40 |
| 41 int32_t SetExpectedRenderDelay(int32_t delay_ms); |
32 | 42 |
33 protected: | 43 protected: |
34 static bool IncomingVideoStreamThreadFun(void* obj); | 44 static bool IncomingVideoStreamThreadFun(void* obj); |
35 bool IncomingVideoStreamProcess(); | 45 bool IncomingVideoStreamProcess(); |
36 | 46 |
37 private: | 47 private: |
38 enum { kEventStartupTimeMs = 10 }; | 48 enum { kEventStartupTimeMs = 10 }; |
39 enum { kEventMaxWaitTimeMs = 100 }; | 49 enum { kEventMaxWaitTimeMs = 100 }; |
40 enum { kFrameRatePeriodMs = 1000 }; | 50 enum { kFrameRatePeriodMs = 1000 }; |
41 | 51 |
42 void OnFrame(const VideoFrame& video_frame) override; | 52 void DeliverFrame(const VideoFrame& video_frame); |
43 | 53 |
44 rtc::ThreadChecker main_thread_checker_; | 54 const bool disable_prerenderer_smoothing_; |
45 rtc::ThreadChecker render_thread_checker_; | 55 // Critsects in allowed to enter order. |
46 rtc::ThreadChecker decoder_thread_checker_; | 56 rtc::CriticalSection stream_critsect_; |
47 | 57 rtc::CriticalSection thread_critsect_; |
48 rtc::CriticalSection buffer_critsect_; | 58 rtc::CriticalSection buffer_critsect_; |
49 rtc::PlatformThread incoming_render_thread_; | 59 // TODO(pbos): Make plain member and stop resetting this thread, just |
| 60 // start/stoping it is enough. |
| 61 std::unique_ptr<rtc::PlatformThread> incoming_render_thread_ |
| 62 GUARDED_BY(thread_critsect_); |
50 std::unique_ptr<EventTimerWrapper> deliver_buffer_event_; | 63 std::unique_ptr<EventTimerWrapper> deliver_buffer_event_; |
51 | 64 |
52 rtc::VideoSinkInterface<VideoFrame>* const external_callback_; | 65 bool running_ GUARDED_BY(stream_critsect_); |
53 std::unique_ptr<VideoRenderFrames> render_buffers_ | 66 rtc::VideoSinkInterface<VideoFrame>* external_callback_ |
| 67 GUARDED_BY(thread_critsect_); |
| 68 const std::unique_ptr<VideoRenderFrames> render_buffers_ |
54 GUARDED_BY(buffer_critsect_); | 69 GUARDED_BY(buffer_critsect_); |
55 }; | 70 }; |
56 | 71 |
57 class IncomingVideoStreamNoSmoothing | |
58 : public rtc::VideoSinkInterface<VideoFrame> { | |
59 public: | |
60 explicit IncomingVideoStreamNoSmoothing( | |
61 rtc::VideoSinkInterface<VideoFrame>* callback); | |
62 | |
63 private: | |
64 // Overrides VideoSinkInterface | |
65 void OnFrame(const VideoFrame& video_frame) override; | |
66 | |
67 rtc::ThreadChecker decoder_thread_checker_; | |
68 rtc::VideoSinkInterface<VideoFrame>* const callback_; | |
69 rtc::TaskQueue queue_; | |
70 }; | |
71 | |
72 } // namespace webrtc | 72 } // namespace webrtc |
73 | 73 |
74 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ | 74 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ |
OLD | NEW |