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