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