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_VIDEO_VIDEO_CAPTURE_INPUT_H_ | 11 #ifndef WEBRTC_VIDEO_VIDEO_CAPTURE_INPUT_H_ |
12 #define WEBRTC_VIDEO_VIDEO_CAPTURE_INPUT_H_ | 12 #define WEBRTC_VIDEO_VIDEO_CAPTURE_INPUT_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/base/event.h" | 17 #include "webrtc/base/event.h" |
| 18 #include "webrtc/base/optional.h" |
18 #include "webrtc/base/platform_thread.h" | 19 #include "webrtc/base/platform_thread.h" |
19 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/base/thread_annotations.h" | 21 #include "webrtc/base/thread_annotations.h" |
21 #include "webrtc/common_types.h" | 22 #include "webrtc/common_types.h" |
22 #include "webrtc/engine_configurations.h" | 23 #include "webrtc/engine_configurations.h" |
23 #include "webrtc/modules/video_capture/video_capture.h" | 24 #include "webrtc/modules/video_capture/video_capture.h" |
24 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 25 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
25 #include "webrtc/modules/video_coding/include/video_coding.h" | 26 #include "webrtc/modules/video_coding/include/video_coding.h" |
26 #include "webrtc/modules/video_processing/include/video_processing.h" | 27 #include "webrtc/modules/video_processing/include/video_processing.h" |
27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 28 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
28 #include "webrtc/typedefs.h" | 29 #include "webrtc/typedefs.h" |
29 #include "webrtc/video_send_stream.h" | 30 #include "webrtc/video_send_stream.h" |
30 | 31 |
31 namespace webrtc { | 32 namespace webrtc { |
32 | 33 |
33 class Config; | 34 class Config; |
34 class CpuOveruseMetricsObserver; | 35 class CpuOveruseMetricsObserver; |
35 class CpuOveruseObserver; | 36 class CpuOveruseObserver; |
36 class CriticalSectionWrapper; | 37 class CriticalSectionWrapper; |
37 class OveruseFrameDetector; | 38 class OveruseFrameDetector; |
38 class ProcessThread; | 39 class ProcessThread; |
39 class RegistrableCpuOveruseMetricsObserver; | 40 class RegistrableCpuOveruseMetricsObserver; |
40 class SendStatisticsProxy; | 41 class SendStatisticsProxy; |
| 42 class VideoCodingModule; |
41 class VideoRenderer; | 43 class VideoRenderer; |
42 | 44 |
43 class VideoCaptureCallback { | 45 class VideoCaptureCallback { |
44 public: | 46 public: |
45 virtual ~VideoCaptureCallback() {} | 47 virtual ~VideoCaptureCallback() {} |
46 | 48 |
47 virtual void DeliverFrame(VideoFrame video_frame) = 0; | 49 virtual void DeliverFrame(VideoFrame video_frame) = 0; |
48 }; | 50 }; |
49 | 51 |
50 namespace internal { | 52 namespace internal { |
| 53 |
| 54 class VideoSendStream; |
51 class VideoCaptureInput : public webrtc::VideoCaptureInput { | 55 class VideoCaptureInput : public webrtc::VideoCaptureInput { |
52 public: | 56 public: |
53 VideoCaptureInput(ProcessThread* module_process_thread, | 57 VideoCaptureInput(ProcessThread* module_process_thread, |
54 VideoCaptureCallback* frame_callback, | 58 VideoCaptureCallback* frame_callback, |
55 VideoRenderer* local_renderer, | 59 VideoCodingModule* vcm, |
| 60 VideoSendStream* video_send_stream, |
| 61 const webrtc::VideoSendStream::Config& config, |
56 SendStatisticsProxy* send_stats_proxy, | 62 SendStatisticsProxy* send_stats_proxy, |
57 CpuOveruseObserver* overuse_observer, | 63 CpuOveruseObserver* overuse_observer); |
58 EncodingTimeObserver* encoding_time_observer); | |
59 ~VideoCaptureInput(); | 64 ~VideoCaptureInput(); |
60 | 65 |
61 void IncomingCapturedFrame(const VideoFrame& video_frame) override; | 66 void IncomingCapturedFrame(const VideoFrame& video_frame) override; |
| 67 void TriggerSetSendCodec(const VideoCodec& video_codec); |
62 | 68 |
63 private: | 69 private: |
64 // Thread functions for deliver captured frames to receivers. | 70 // Thread functions for deliver captured frames to receivers. |
65 static bool EncoderThreadFunction(void* obj); | 71 static bool EncoderThreadFunction(void* obj); |
66 bool EncoderProcess(); | 72 bool EncoderProcess(); |
67 | 73 |
68 rtc::scoped_ptr<CriticalSectionWrapper> capture_cs_; | 74 rtc::scoped_ptr<CriticalSectionWrapper> capture_cs_; |
69 ProcessThread* const module_process_thread_; | 75 ProcessThread* const module_process_thread_; |
70 | 76 |
71 VideoCaptureCallback* const frame_callback_; | 77 VideoCaptureCallback* const frame_callback_; |
72 VideoRenderer* const local_renderer_; | 78 VideoCodingModule* const vcm_; |
| 79 VideoSendStream* const video_send_stream_; |
| 80 const webrtc::VideoSendStream::Config config_; |
| 81 bool encoder_registered_; |
73 SendStatisticsProxy* const stats_proxy_; | 82 SendStatisticsProxy* const stats_proxy_; |
74 | 83 |
75 // Frame used in IncomingFrameI420. | |
76 rtc::scoped_ptr<CriticalSectionWrapper> incoming_frame_cs_; | |
77 VideoFrame incoming_frame_; | |
78 | |
79 rtc::PlatformThread encoder_thread_; | 84 rtc::PlatformThread encoder_thread_; |
80 rtc::Event capture_event_; | 85 rtc::Event capture_event_; |
81 | 86 |
82 volatile int stop_; | 87 volatile int stop_; |
83 | 88 |
84 VideoFrame captured_frame_ GUARDED_BY(capture_cs_.get()); | 89 rtc::Optional<VideoCodec> replacement_codec_settings_ GUARDED_BY(capture_cs_); |
| 90 VideoFrame captured_frame_ GUARDED_BY(capture_cs_); |
85 // Used to make sure incoming time stamp is increasing for every frame. | 91 // Used to make sure incoming time stamp is increasing for every frame. |
86 int64_t last_captured_timestamp_; | 92 int64_t last_captured_timestamp_; |
87 // Delta used for translating between NTP and internal timestamps. | 93 // Delta used for translating between NTP and internal timestamps. |
88 const int64_t delta_ntp_internal_ms_; | 94 const int64_t delta_ntp_internal_ms_; |
89 | 95 |
90 rtc::scoped_ptr<OveruseFrameDetector> overuse_detector_; | 96 rtc::scoped_ptr<OveruseFrameDetector> overuse_detector_; |
91 EncodingTimeObserver* const encoding_time_observer_; | |
92 }; | 97 }; |
93 | 98 |
94 } // namespace internal | 99 } // namespace internal |
95 } // namespace webrtc | 100 } // namespace webrtc |
96 | 101 |
97 #endif // WEBRTC_VIDEO_VIDEO_CAPTURE_INPUT_H_ | 102 #endif // WEBRTC_VIDEO_VIDEO_CAPTURE_INPUT_H_ |
OLD | NEW |