1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ 13 14 #include <memory> 15 16 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/platform_thread.h" 18 #include "webrtc/base/race_checker.h" 19 #include "webrtc/base/thread_annotations.h" 20 #include "webrtc/base/thread_checker.h" 21 #include "webrtc/common_video/video_render_frames.h" 22 #include "webrtc/media/base/videosinkinterface.h" 23 24 namespace webrtc { 25 class EventTimerWrapper; 26 27 class IncomingVideoStream : public rtc::VideoSinkInterface<VideoFrame> { 28 public: 29 IncomingVideoStream(int32_t delay_ms, 30 rtc::VideoSinkInterface<VideoFrame>* callback); 31 ~IncomingVideoStream() override; 32 33 protected: 34 static bool IncomingVideoStreamThreadFun(void* obj); 35 bool IncomingVideoStreamProcess(); 36 37 private: 38 enum { kEventStartupTimeMs = 10 }; 39 enum { kEventMaxWaitTimeMs = 100 }; 40 enum { kFrameRatePeriodMs = 1000 }; 41 42 void OnFrame(const VideoFrame& video_frame) override; 43 44 rtc::ThreadChecker main_thread_checker_; 45 rtc::ThreadChecker render_thread_checker_; 46 rtc::RaceChecker decoder_race_checker_; 47 48 rtc::CriticalSection buffer_critsect_; 49 rtc::PlatformThread incoming_render_thread_; 50 std::unique_ptr<EventTimerWrapper> deliver_buffer_event_; 51 52 rtc::VideoSinkInterface<VideoFrame>* const external_callback_; 53 std::unique_ptr<VideoRenderFrames> render_buffers_ 54 GUARDED_BY(buffer_critsect_); 55 }; 56 57 } // namespace webrtc 58 59 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_ 60