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

Side by Side Diff: webrtc/sdk/android/src/jni/videoencoderwrapper.cc

Issue 3002783002: Android: Use injectable hardware video decoder in AppRTCMobile.
Patch Set: Rebase Created 3 years, 3 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
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 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
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 FindClass(jni, "org/webrtc/VideoEncoder$ScalingSettings"); 90 FindClass(jni, "org/webrtc/VideoEncoder$ScalingSettings");
91 scaling_settings_on_field_ = 91 scaling_settings_on_field_ =
92 jni->GetFieldID(scaling_settings_class, "on", "Z"); 92 jni->GetFieldID(scaling_settings_class, "on", "Z");
93 scaling_settings_low_field_ = 93 scaling_settings_low_field_ =
94 jni->GetFieldID(scaling_settings_class, "low", "Ljava/lang/Integer;"); 94 jni->GetFieldID(scaling_settings_class, "low", "Ljava/lang/Integer;");
95 scaling_settings_high_field_ = 95 scaling_settings_high_field_ =
96 jni->GetFieldID(scaling_settings_class, "high", "Ljava/lang/Integer;"); 96 jni->GetFieldID(scaling_settings_class, "high", "Ljava/lang/Integer;");
97 97
98 implementation_name_ = GetImplementationName(jni); 98 implementation_name_ = GetImplementationName(jni);
99 99
100 encoder_queue_ = rtc::TaskQueue::Current();
101
102 initialized_ = false; 100 initialized_ = false;
103 num_resets_ = 0; 101 num_resets_ = 0;
104 102
105 Random random(rtc::TimeMicros()); 103 Random random(rtc::TimeMicros());
106 picture_id_ = random.Rand<uint16_t>() & 0x7FFF; 104 picture_id_ = random.Rand<uint16_t>() & 0x7FFF;
107 tl0_pic_idx_ = random.Rand<uint8_t>(); 105 tl0_pic_idx_ = random.Rand<uint8_t>();
108 } 106 }
109 107
110 int32_t VideoEncoderWrapper::InitEncode(const VideoCodec* codec_settings, 108 int32_t VideoEncoderWrapper::InitEncode(const VideoCodec* codec_settings,
111 int32_t number_of_cores, 109 int32_t number_of_cores,
112 size_t max_payload_size) { 110 size_t max_payload_size) {
113 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 111 JNIEnv* jni = AttachCurrentThreadIfNeeded();
114 ScopedLocalRefFrame local_ref_frame(jni); 112 ScopedLocalRefFrame local_ref_frame(jni);
115 113
116 number_of_cores_ = number_of_cores; 114 number_of_cores_ = number_of_cores;
117 codec_settings_ = *codec_settings; 115 codec_settings_ = *codec_settings;
118 num_resets_ = 0; 116 num_resets_ = 0;
117 encoder_queue_ = rtc::TaskQueue::Current();
119 118
120 return InitEncodeInternal(jni); 119 return InitEncodeInternal(jni);
121 } 120 }
122 121
123 int32_t VideoEncoderWrapper::InitEncodeInternal(JNIEnv* jni) { 122 int32_t VideoEncoderWrapper::InitEncodeInternal(JNIEnv* jni) {
124 bool automatic_resize_on; 123 bool automatic_resize_on;
125 switch (codec_settings_.codecType) { 124 switch (codec_settings_.codecType) {
126 case kVideoCodecVP8: 125 case kVideoCodecVP8:
127 automatic_resize_on = codec_settings_.VP8()->automaticResizeOn; 126 automatic_resize_on = codec_settings_.VP8()->automaticResizeOn;
128 break; 127 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 callback_ = callback; 159 callback_ = callback;
161 return WEBRTC_VIDEO_CODEC_OK; 160 return WEBRTC_VIDEO_CODEC_OK;
162 } 161 }
163 162
164 int32_t VideoEncoderWrapper::Release() { 163 int32_t VideoEncoderWrapper::Release() {
165 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 164 JNIEnv* jni = AttachCurrentThreadIfNeeded();
166 ScopedLocalRefFrame local_ref_frame(jni); 165 ScopedLocalRefFrame local_ref_frame(jni);
167 jobject ret = jni->CallObjectMethod(*encoder_, release_method_); 166 jobject ret = jni->CallObjectMethod(*encoder_, release_method_);
168 frame_extra_infos_.clear(); 167 frame_extra_infos_.clear();
169 initialized_ = false; 168 initialized_ = false;
169 encoder_queue_ = nullptr;
170 return HandleReturnCode(jni, ret); 170 return HandleReturnCode(jni, ret);
171 } 171 }
172 172
173 int32_t VideoEncoderWrapper::Encode( 173 int32_t VideoEncoderWrapper::Encode(
174 const VideoFrame& frame, 174 const VideoFrame& frame,
175 const CodecSpecificInfo* /* codec_specific_info */, 175 const CodecSpecificInfo* /* codec_specific_info */,
176 const std::vector<FrameType>* frame_types) { 176 const std::vector<FrameType>* frame_types) {
177 if (!initialized_) { 177 if (!initialized_) {
178 // Most likely initializing the codec failed. 178 // Most likely initializing the codec failed.
179 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; 179 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 jobject qp) { 481 jobject qp) {
482 VideoEncoderWrapper* native_encoder = 482 VideoEncoderWrapper* native_encoder =
483 reinterpret_cast<VideoEncoderWrapper*>(j_native_encoder); 483 reinterpret_cast<VideoEncoderWrapper*>(j_native_encoder);
484 native_encoder->OnEncodedFrame(jni, buffer, encoded_width, encoded_height, 484 native_encoder->OnEncodedFrame(jni, buffer, encoded_width, encoded_height,
485 capture_time_ns, frame_type, rotation, 485 capture_time_ns, frame_type, rotation,
486 complete_frame, qp); 486 complete_frame, qp);
487 } 487 }
488 488
489 } // namespace jni 489 } // namespace jni
490 } // namespace webrtc 490 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698