Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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/api/androidvideocapturer.h" | 11 #include "webrtc/api/androidvideocapturer.h" |
| 12 | 12 |
| 13 #include "webrtc/api/java/jni/native_handle_impl.h" | 13 #include "webrtc/api/java/jni/native_handle_impl.h" |
| 14 #include "webrtc/base/common.h" | 14 #include "webrtc/base/common.h" |
| 15 #include "webrtc/base/json.h" | |
| 16 #include "webrtc/base/timeutils.h" | 15 #include "webrtc/base/timeutils.h" |
| 17 #include "webrtc/media/engine/webrtcvideoframe.h" | 16 #include "webrtc/media/engine/webrtcvideoframe.h" |
| 18 | 17 |
| 19 namespace webrtc { | 18 namespace webrtc { |
| 20 | 19 |
| 21 // A hack for avoiding deep frame copies in | 20 // A hack for avoiding deep frame copies in |
| 22 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory. | 21 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory. |
| 23 // A frame is injected using UpdateCapturedFrame(), and converted into a | 22 // A frame is injected using UpdateCapturedFrame(), and converted into a |
| 24 // cricket::VideoFrame with CreateAliasedFrame(). UpdateCapturedFrame() should | 23 // cricket::VideoFrame with CreateAliasedFrame(). UpdateCapturedFrame() should |
| 25 // be called before CreateAliasedFrame() for every frame. | 24 // be called before CreateAliasedFrame() for every frame. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 rtc::scoped_refptr<AndroidVideoCapturerDelegate> delegate_; | 111 rtc::scoped_refptr<AndroidVideoCapturerDelegate> delegate_; |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 AndroidVideoCapturer::AndroidVideoCapturer( | 114 AndroidVideoCapturer::AndroidVideoCapturer( |
| 116 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate) | 115 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate) |
| 117 : running_(false), | 116 : running_(false), |
| 118 delegate_(delegate), | 117 delegate_(delegate), |
| 119 frame_factory_(NULL), | 118 frame_factory_(NULL), |
| 120 current_state_(cricket::CS_STOPPED) { | 119 current_state_(cricket::CS_STOPPED) { |
| 121 thread_checker_.DetachFromThread(); | 120 thread_checker_.DetachFromThread(); |
| 122 std::string json_string = delegate_->GetSupportedFormats(); | 121 const std::vector<cricket::VideoFormat> formats = |
| 123 LOG(LS_INFO) << json_string; | 122 delegate_->GetSupportedFormats(); |
| 124 | 123 LOG(LS_INFO) << formats.size() << " supported formats: "; |
|
perkj_webrtc
2016/02/16 14:35:41
is this logged in Java- if so - remove from here.
magjed_webrtc
2016/02/18 10:43:35
Done, but this will be a change from current code.
| |
| 125 Json::Value json_values; | 124 for (const cricket::VideoFormat& format : formats) { |
| 126 Json::Reader reader(Json::Features::strictMode()); | 125 LOG(LS_INFO) << format.width << "x" << format.height << "@" |
| 127 if (!reader.parse(json_string, json_values)) { | 126 << format.framerate(); |
| 128 LOG(LS_ERROR) << "Failed to parse formats."; | |
| 129 } | |
| 130 | |
| 131 std::vector<cricket::VideoFormat> formats; | |
| 132 for (Json::ArrayIndex i = 0; i < json_values.size(); ++i) { | |
| 133 const Json::Value& json_value = json_values[i]; | |
| 134 RTC_CHECK(!json_value["width"].isNull() && | |
| 135 !json_value["height"].isNull() && | |
| 136 !json_value["framerate"].isNull()); | |
| 137 cricket::VideoFormat format( | |
| 138 json_value["width"].asInt(), | |
| 139 json_value["height"].asInt(), | |
| 140 cricket::VideoFormat::FpsToInterval(json_value["framerate"].asInt()), | |
| 141 cricket::FOURCC_YV12); | |
| 142 formats.push_back(format); | |
| 143 } | 127 } |
| 144 SetSupportedFormats(formats); | 128 SetSupportedFormats(formats); |
| 145 } | 129 } |
| 146 | 130 |
| 147 AndroidVideoCapturer::~AndroidVideoCapturer() { | 131 AndroidVideoCapturer::~AndroidVideoCapturer() { |
| 148 RTC_CHECK(!running_); | 132 RTC_CHECK(!running_); |
| 149 } | 133 } |
| 150 | 134 |
| 151 cricket::CaptureState AndroidVideoCapturer::Start( | 135 cricket::CaptureState AndroidVideoCapturer::Start( |
| 152 const cricket::VideoFormat& capture_format) { | 136 const cricket::VideoFormat& capture_format) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 208 |
| 225 bool AndroidVideoCapturer::GetBestCaptureFormat( | 209 bool AndroidVideoCapturer::GetBestCaptureFormat( |
| 226 const cricket::VideoFormat& desired, | 210 const cricket::VideoFormat& desired, |
| 227 cricket::VideoFormat* best_format) { | 211 cricket::VideoFormat* best_format) { |
| 228 // Delegate this choice to VideoCapturer.startCapture(). | 212 // Delegate this choice to VideoCapturer.startCapture(). |
| 229 *best_format = desired; | 213 *best_format = desired; |
| 230 return true; | 214 return true; |
| 231 } | 215 } |
| 232 | 216 |
| 233 } // namespace webrtc | 217 } // namespace webrtc |
| OLD | NEW |