OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 #include "talk/app/webrtc/androidvideocapturer.h" | 27 #include "talk/app/webrtc/androidvideocapturer.h" |
28 | 28 |
29 #include "talk/app/webrtc/java/jni/native_handle_impl.h" | |
29 #include "talk/media/webrtc/webrtcvideoframe.h" | 30 #include "talk/media/webrtc/webrtcvideoframe.h" |
30 #include "webrtc/base/common.h" | 31 #include "webrtc/base/common.h" |
31 #include "webrtc/base/json.h" | 32 #include "webrtc/base/json.h" |
32 #include "webrtc/base/timeutils.h" | 33 #include "webrtc/base/timeutils.h" |
33 | 34 |
34 namespace webrtc { | 35 namespace webrtc { |
35 | 36 |
36 // A hack for avoiding deep frame copies in | 37 // A hack for avoiding deep frame copies in |
37 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory. | 38 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory. |
38 // A frame is injected using UpdateCapturedFrame(), and converted into a | 39 // A frame is injected using UpdateCapturedFrame(), and converted into a |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy() | 94 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy() |
94 : frame.release(); | 95 : frame.release(); |
95 } | 96 } |
96 | 97 |
97 cricket::VideoFrame* CreateAliasedFrame( | 98 cricket::VideoFrame* CreateAliasedFrame( |
98 const cricket::CapturedFrame* input_frame, | 99 const cricket::CapturedFrame* input_frame, |
99 int cropped_input_width, | 100 int cropped_input_width, |
100 int cropped_input_height, | 101 int cropped_input_height, |
101 int output_width, | 102 int output_width, |
102 int output_height) const override { | 103 int output_height) const override { |
104 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(buffer_); | |
magjed_webrtc
2015/11/25 13:38:28
Move this inside the if-statement, i.e.
rtc::scope
perkj_webrtc
2015/11/25 20:56:20
Done.
| |
103 if (buffer_->native_handle() != nullptr) { | 105 if (buffer_->native_handle() != nullptr) { |
104 // TODO(perkj): Implement CreateAliasedFrame properly for textures. | 106 buffer = static_cast<webrtc_jni::AndroidTextureBuffer*>(buffer_.get()) |
107 ->CropAndScale(cropped_input_width, cropped_input_height, | |
108 output_width, output_height); | |
105 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( | 109 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( |
106 buffer_, input_frame->time_stamp, input_frame->rotation)); | 110 buffer, input_frame->time_stamp, input_frame->rotation)); |
107 return frame.release(); | 111 return frame.release(); |
108 } | 112 } |
109 return VideoFrameFactory::CreateAliasedFrame(input_frame, | 113 return VideoFrameFactory::CreateAliasedFrame(input_frame, |
110 cropped_input_width, | 114 cropped_input_width, |
111 cropped_input_height, | 115 cropped_input_height, |
112 output_width, | 116 output_width, |
113 output_height); | 117 output_height); |
114 } | 118 } |
115 | 119 |
116 private: | 120 private: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 | 237 |
234 bool AndroidVideoCapturer::GetBestCaptureFormat( | 238 bool AndroidVideoCapturer::GetBestCaptureFormat( |
235 const cricket::VideoFormat& desired, | 239 const cricket::VideoFormat& desired, |
236 cricket::VideoFormat* best_format) { | 240 cricket::VideoFormat* best_format) { |
237 // Delegate this choice to VideoCapturerAndroid.startCapture(). | 241 // Delegate this choice to VideoCapturerAndroid.startCapture(). |
238 *best_format = desired; | 242 *best_format = desired; |
239 return true; | 243 return true; |
240 } | 244 } |
241 | 245 |
242 } // namespace webrtc | 246 } // namespace webrtc |
OLD | NEW |