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

Side by Side Diff: talk/media/webrtc/webrtcvideoengine2.cc

Issue 1187573004: iOS HW H264 support. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Move unittest file. Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 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,
(...skipping 25 matching lines...) Expand all
36 #include "talk/media/base/videorenderer.h" 36 #include "talk/media/base/videorenderer.h"
37 #include "talk/media/webrtc/constants.h" 37 #include "talk/media/webrtc/constants.h"
38 #include "talk/media/webrtc/simulcast.h" 38 #include "talk/media/webrtc/simulcast.h"
39 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" 39 #include "talk/media/webrtc/webrtcvideoencoderfactory.h"
40 #include "talk/media/webrtc/webrtcvideoframe.h" 40 #include "talk/media/webrtc/webrtcvideoframe.h"
41 #include "talk/media/webrtc/webrtcvoiceengine.h" 41 #include "talk/media/webrtc/webrtcvoiceengine.h"
42 #include "webrtc/base/buffer.h" 42 #include "webrtc/base/buffer.h"
43 #include "webrtc/base/logging.h" 43 #include "webrtc/base/logging.h"
44 #include "webrtc/base/stringutils.h" 44 #include "webrtc/base/stringutils.h"
45 #include "webrtc/call.h" 45 #include "webrtc/call.h"
46 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
46 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" 47 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
47 #include "webrtc/system_wrappers/interface/field_trial.h" 48 #include "webrtc/system_wrappers/interface/field_trial.h"
48 #include "webrtc/system_wrappers/interface/trace_event.h" 49 #include "webrtc/system_wrappers/interface/trace_event.h"
49 #include "webrtc/video_decoder.h" 50 #include "webrtc/video_decoder.h"
50 #include "webrtc/video_encoder.h" 51 #include "webrtc/video_encoder.h"
51 52
52 #define UNIMPLEMENTED \ 53 #define UNIMPLEMENTED \
53 LOG(LS_ERROR) << "Call to unimplemented function " << __FUNCTION__; \ 54 LOG(LS_ERROR) << "Call to unimplemented function " << __FUNCTION__; \
54 RTC_NOTREACHED() 55 RTC_NOTREACHED()
55 56
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 bool CodecIsInternallySupported(const std::string& codec_name) { 152 bool CodecIsInternallySupported(const std::string& codec_name) {
152 if (CodecNamesEq(codec_name, kVp8CodecName)) { 153 if (CodecNamesEq(codec_name, kVp8CodecName)) {
153 return true; 154 return true;
154 } 155 }
155 if (CodecNamesEq(codec_name, kVp9CodecName)) { 156 if (CodecNamesEq(codec_name, kVp9CodecName)) {
156 const std::string group_name = 157 const std::string group_name =
157 webrtc::field_trial::FindFullName("WebRTC-SupportVP9"); 158 webrtc::field_trial::FindFullName("WebRTC-SupportVP9");
158 return group_name == "Enabled" || group_name == "EnabledByFlag"; 159 return group_name == "Enabled" || group_name == "EnabledByFlag";
159 } 160 }
161 if (CodecNamesEq(codec_name, kH264CodecName)) {
162 return webrtc::H264Encoder::IsSupported() &&
163 webrtc::H264Decoder::IsSupported();
164 }
160 return false; 165 return false;
161 } 166 }
162 167
163 void AddDefaultFeedbackParams(VideoCodec* codec) { 168 void AddDefaultFeedbackParams(VideoCodec* codec) {
164 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir)); 169 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir));
165 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); 170 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty));
166 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); 171 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli));
167 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty)); 172 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty));
168 } 173 }
169 174
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 const int kVideoRtpBufferSize = 65536; 314 const int kVideoRtpBufferSize = 65536;
310 315
311 // This constant is really an on/off, lower-level configurable NACK history 316 // This constant is really an on/off, lower-level configurable NACK history
312 // duration hasn't been implemented. 317 // duration hasn't been implemented.
313 static const int kNackHistoryMs = 1000; 318 static const int kNackHistoryMs = 1000;
314 319
315 static const int kDefaultQpMax = 56; 320 static const int kDefaultQpMax = 56;
316 321
317 static const int kDefaultRtcpReceiverReportSsrc = 1; 322 static const int kDefaultRtcpReceiverReportSsrc = 1;
318 323
319 const char kH264CodecName[] = "H264";
320
321 const int kMinBandwidthBps = 30000; 324 const int kMinBandwidthBps = 30000;
322 const int kStartBandwidthBps = 300000; 325 const int kStartBandwidthBps = 300000;
323 const int kMaxBandwidthBps = 2000000; 326 const int kMaxBandwidthBps = 2000000;
324 327
325 std::vector<VideoCodec> DefaultVideoCodecList() { 328 std::vector<VideoCodec> DefaultVideoCodecList() {
326 std::vector<VideoCodec> codecs; 329 std::vector<VideoCodec> codecs;
327 if (CodecIsInternallySupported(kVp9CodecName)) { 330 if (CodecIsInternallySupported(kVp9CodecName)) {
328 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp9PlType, 331 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp9PlType,
329 kVp9CodecName)); 332 kVp9CodecName));
330 // TODO(andresp): Add rtx codec for vp9 and verify it works. 333 // TODO(andresp): Add rtx codec for vp9 and verify it works.
331 } 334 }
332 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType, 335 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType,
333 kVp8CodecName)); 336 kVp8CodecName));
337 if (CodecIsInternallySupported(kH264CodecName)) {
338 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultH264PlType,
339 kH264CodecName));
340 }
334 codecs.push_back( 341 codecs.push_back(
335 VideoCodec::CreateRtxCodec(kDefaultRtxVp8PlType, kDefaultVp8PlType)); 342 VideoCodec::CreateRtxCodec(kDefaultRtxVp8PlType, kDefaultVp8PlType));
336 codecs.push_back(VideoCodec(kDefaultRedPlType, kRedCodecName)); 343 codecs.push_back(VideoCodec(kDefaultRedPlType, kRedCodecName));
337 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName)); 344 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName));
338 return codecs; 345 return codecs;
339 } 346 }
340 347
341 static bool FindFirstMatchingCodec(const std::vector<VideoCodec>& codecs, 348 static bool FindFirstMatchingCodec(const std::vector<VideoCodec>& codecs,
342 const VideoCodec& requested_codec, 349 const VideoCodec& requested_codec,
343 VideoCodec* matching_codec) { 350 VideoCodec* matching_codec) {
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 return AllocatedEncoder(encoder, type, true); 1876 return AllocatedEncoder(encoder, type, true);
1870 } 1877 }
1871 } 1878 }
1872 1879
1873 if (type == webrtc::kVideoCodecVP8) { 1880 if (type == webrtc::kVideoCodecVP8) {
1874 return AllocatedEncoder( 1881 return AllocatedEncoder(
1875 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8), type, false); 1882 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8), type, false);
1876 } else if (type == webrtc::kVideoCodecVP9) { 1883 } else if (type == webrtc::kVideoCodecVP9) {
1877 return AllocatedEncoder( 1884 return AllocatedEncoder(
1878 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp9), type, false); 1885 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp9), type, false);
1886 } else if (type == webrtc::kVideoCodecH264) {
1887 return AllocatedEncoder(
1888 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kH264), type, false);
1879 } 1889 }
1880 1890
1881 // This shouldn't happen, we should not be trying to create something we don't 1891 // This shouldn't happen, we should not be trying to create something we don't
1882 // support. 1892 // support.
1883 DCHECK(false); 1893 DCHECK(false);
1884 return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false); 1894 return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false);
1885 } 1895 }
1886 1896
1887 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( 1897 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder(
1888 AllocatedEncoder* encoder) { 1898 AllocatedEncoder* encoder) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 if (type == webrtc::kVideoCodecVP8) { 2287 if (type == webrtc::kVideoCodecVP8) {
2278 return AllocatedDecoder( 2288 return AllocatedDecoder(
2279 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false); 2289 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false);
2280 } 2290 }
2281 2291
2282 if (type == webrtc::kVideoCodecVP9) { 2292 if (type == webrtc::kVideoCodecVP9) {
2283 return AllocatedDecoder( 2293 return AllocatedDecoder(
2284 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp9), type, false); 2294 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp9), type, false);
2285 } 2295 }
2286 2296
2297 if (type == webrtc::kVideoCodecH264) {
2298 return AllocatedDecoder(
2299 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kH264), type, false);
2300 }
2301
2287 // This shouldn't happen, we should not be trying to create something we don't 2302 // This shouldn't happen, we should not be trying to create something we don't
2288 // support. 2303 // support.
2289 DCHECK(false); 2304 DCHECK(false);
2290 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false); 2305 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false);
2291 } 2306 }
2292 2307
2293 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs( 2308 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs(
2294 const std::vector<VideoCodecSettings>& recv_codecs) { 2309 const std::vector<VideoCodecSettings>& recv_codecs) {
2295 std::vector<AllocatedDecoder> old_decoders = allocated_decoders_; 2310 std::vector<AllocatedDecoder> old_decoders = allocated_decoders_;
2296 allocated_decoders_.clear(); 2311 allocated_decoders_.clear();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2595 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2581 } 2596 }
2582 } 2597 }
2583 2598
2584 return video_codecs; 2599 return video_codecs;
2585 } 2600 }
2586 2601
2587 } // namespace cricket 2602 } // namespace cricket
2588 2603
2589 #endif // HAVE_WEBRTC_VIDEO 2604 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698