OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/media/base/adaptedvideotracksource.h" | 11 #include "webrtc/media/base/adaptedvideotracksource.h" |
12 | 12 |
13 namespace rtc { | 13 namespace rtc { |
14 | 14 |
15 AdaptedVideoTrackSource::AdaptedVideoTrackSource() { | 15 AdaptedVideoTrackSource::AdaptedVideoTrackSource() { |
16 thread_checker_.DetachFromThread(); | 16 thread_checker_.DetachFromThread(); |
17 } | 17 } |
18 | 18 |
19 bool AdaptedVideoTrackSource::GetStats(Stats* stats) { | 19 bool AdaptedVideoTrackSource::GetStats(Stats* stats) { |
20 rtc::CritScope lock(&stats_crit_); | 20 rtc::CritScope lock(&stats_crit_); |
21 | 21 |
22 if (!stats_) { | 22 if (!stats_) { |
23 return false; | 23 return false; |
24 } | 24 } |
25 | 25 |
26 *stats = *stats_; | 26 *stats = *stats_; |
27 return true; | 27 return true; |
28 } | 28 } |
29 | 29 |
30 void AdaptedVideoTrackSource::OnFrame(const webrtc::VideoFrame& frame) { | 30 void AdaptedVideoTrackSource::OnFrame(const cricket::VideoFrame& frame) { |
31 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( | 31 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
32 frame.video_frame_buffer()); | 32 frame.video_frame_buffer()); |
33 /* Note that this is a "best effort" approach to | 33 /* Note that this is a "best effort" approach to |
34 wants.rotation_applied; apply_rotation_ can change from false to | 34 wants.rotation_applied; apply_rotation_ can change from false to |
35 true between the check of apply_rotation() and the call to | 35 true between the check of apply_rotation() and the call to |
36 broadcaster_.OnFrame(), in which case we generate a frame with | 36 broadcaster_.OnFrame(), in which case we generate a frame with |
37 pending rotation despite some sink with wants.rotation_applied == | 37 pending rotation despite some sink with wants.rotation_applied == |
38 true was just added. The VideoBroadcaster enforces | 38 true was just added. The VideoBroadcaster enforces |
39 synchronization for us in this case, by not passing the frame on | 39 synchronization for us in this case, by not passing the frame on |
40 to sinks which don't want it. */ | 40 to sinks which don't want it. */ |
41 if (apply_rotation() && | 41 if (apply_rotation() && |
42 frame.rotation() != webrtc::kVideoRotation_0 && | 42 frame.rotation() != webrtc::kVideoRotation_0 && |
43 !buffer->native_handle()) { | 43 !buffer->native_handle()) { |
44 /* Apply pending rotation. */ | 44 /* Apply pending rotation. */ |
45 broadcaster_.OnFrame(webrtc::VideoFrame( | 45 broadcaster_.OnFrame(cricket::WebRtcVideoFrame( |
46 webrtc::I420Buffer::Rotate(buffer, frame.rotation()), | 46 webrtc::I420Buffer::Rotate(buffer, frame.rotation()), |
47 webrtc::kVideoRotation_0, frame.timestamp_us())); | 47 webrtc::kVideoRotation_0, frame.timestamp_us())); |
48 } else { | 48 } else { |
49 broadcaster_.OnFrame(frame); | 49 broadcaster_.OnFrame(frame); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 void AdaptedVideoTrackSource::AddOrUpdateSink( | 53 void AdaptedVideoTrackSource::AddOrUpdateSink( |
54 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink, | 54 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
55 const rtc::VideoSinkWants& wants) { | 55 const rtc::VideoSinkWants& wants) { |
56 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 56 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
57 | 57 |
58 broadcaster_.AddOrUpdateSink(sink, wants); | 58 broadcaster_.AddOrUpdateSink(sink, wants); |
59 OnSinkWantsChanged(broadcaster_.wants()); | 59 OnSinkWantsChanged(broadcaster_.wants()); |
60 } | 60 } |
61 | 61 |
62 void AdaptedVideoTrackSource::RemoveSink( | 62 void AdaptedVideoTrackSource::RemoveSink( |
63 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 63 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
64 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 64 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
65 | 65 |
66 broadcaster_.RemoveSink(sink); | 66 broadcaster_.RemoveSink(sink); |
67 OnSinkWantsChanged(broadcaster_.wants()); | 67 OnSinkWantsChanged(broadcaster_.wants()); |
68 } | 68 } |
69 | 69 |
70 bool AdaptedVideoTrackSource::apply_rotation() { | 70 bool AdaptedVideoTrackSource::apply_rotation() { |
71 return broadcaster_.wants().rotation_applied; | 71 return broadcaster_.wants().rotation_applied; |
72 } | 72 } |
73 | 73 |
(...skipping 28 matching lines...) Expand all Loading... |
102 // VideoAdapter dropped the frame. | 102 // VideoAdapter dropped the frame. |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 *crop_x = (width - *crop_width) / 2; | 106 *crop_x = (width - *crop_width) / 2; |
107 *crop_y = (height - *crop_height) / 2; | 107 *crop_y = (height - *crop_height) / 2; |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 } // namespace rtc | 111 } // namespace rtc |
OLD | NEW |