Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: webrtc/common_video/include/incoming_video_stream.h

Issue 2071473002: Reland of Split IncomingVideoStream into two implementations, with smoothing and without. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: add explicit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 IncomingVideoStream(int32_t delay_ms,
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::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_
OLDNEW
« no previous file with comments | « webrtc/common_video/common_video_unittests.gyp ('k') | webrtc/common_video/incoming_video_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698