OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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::IsH264CodecSupported(); | |
pbos-webrtc
2015/06/25 20:20:14
H264Encoder::IsSupported() && H264Decoder::IsSuppo
tkchin_webrtc
2015/06/25 21:37:49
Done.
| |
163 } | |
160 return false; | 164 return false; |
161 } | 165 } |
162 | 166 |
163 void AddDefaultFeedbackParams(VideoCodec* codec) { | 167 void AddDefaultFeedbackParams(VideoCodec* codec) { |
164 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir)); | 168 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir)); |
165 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); | 169 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); |
166 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); | 170 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); |
167 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty)); | 171 codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty)); |
168 } | 172 } |
169 | 173 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 const int kVideoRtpBufferSize = 65536; | 313 const int kVideoRtpBufferSize = 65536; |
310 | 314 |
311 // This constant is really an on/off, lower-level configurable NACK history | 315 // This constant is really an on/off, lower-level configurable NACK history |
312 // duration hasn't been implemented. | 316 // duration hasn't been implemented. |
313 static const int kNackHistoryMs = 1000; | 317 static const int kNackHistoryMs = 1000; |
314 | 318 |
315 static const int kDefaultQpMax = 56; | 319 static const int kDefaultQpMax = 56; |
316 | 320 |
317 static const int kDefaultRtcpReceiverReportSsrc = 1; | 321 static const int kDefaultRtcpReceiverReportSsrc = 1; |
318 | 322 |
319 const char kH264CodecName[] = "H264"; | |
320 | |
321 const int kMinBandwidthBps = 30000; | 323 const int kMinBandwidthBps = 30000; |
322 const int kStartBandwidthBps = 300000; | 324 const int kStartBandwidthBps = 300000; |
323 const int kMaxBandwidthBps = 2000000; | 325 const int kMaxBandwidthBps = 2000000; |
324 | 326 |
325 std::vector<VideoCodec> DefaultVideoCodecList() { | 327 std::vector<VideoCodec> DefaultVideoCodecList() { |
326 std::vector<VideoCodec> codecs; | 328 std::vector<VideoCodec> codecs; |
327 if (CodecIsInternallySupported(kVp9CodecName)) { | 329 if (CodecIsInternallySupported(kVp9CodecName)) { |
328 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp9PlType, | 330 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp9PlType, |
329 kVp9CodecName)); | 331 kVp9CodecName)); |
330 // TODO(andresp): Add rtx codec for vp9 and verify it works. | 332 // TODO(andresp): Add rtx codec for vp9 and verify it works. |
331 } | 333 } |
332 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType, | 334 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType, |
333 kVp8CodecName)); | 335 kVp8CodecName)); |
336 if (CodecIsInternallySupported(kH264CodecName)) { | |
337 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultH264PlType, | |
338 kH264CodecName)); | |
339 } | |
334 codecs.push_back( | 340 codecs.push_back( |
335 VideoCodec::CreateRtxCodec(kDefaultRtxVp8PlType, kDefaultVp8PlType)); | 341 VideoCodec::CreateRtxCodec(kDefaultRtxVp8PlType, kDefaultVp8PlType)); |
336 codecs.push_back(VideoCodec(kDefaultRedPlType, kRedCodecName)); | 342 codecs.push_back(VideoCodec(kDefaultRedPlType, kRedCodecName)); |
337 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName)); | 343 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName)); |
338 return codecs; | 344 return codecs; |
339 } | 345 } |
340 | 346 |
341 static bool FindFirstMatchingCodec(const std::vector<VideoCodec>& codecs, | 347 static bool FindFirstMatchingCodec(const std::vector<VideoCodec>& codecs, |
342 const VideoCodec& requested_codec, | 348 const VideoCodec& requested_codec, |
343 VideoCodec* matching_codec) { | 349 VideoCodec* matching_codec) { |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1869 return AllocatedEncoder(encoder, type, true); | 1875 return AllocatedEncoder(encoder, type, true); |
1870 } | 1876 } |
1871 } | 1877 } |
1872 | 1878 |
1873 if (type == webrtc::kVideoCodecVP8) { | 1879 if (type == webrtc::kVideoCodecVP8) { |
1874 return AllocatedEncoder( | 1880 return AllocatedEncoder( |
1875 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8), type, false); | 1881 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8), type, false); |
1876 } else if (type == webrtc::kVideoCodecVP9) { | 1882 } else if (type == webrtc::kVideoCodecVP9) { |
1877 return AllocatedEncoder( | 1883 return AllocatedEncoder( |
1878 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp9), type, false); | 1884 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp9), type, false); |
1885 } else if (type == webrtc::kVideoCodecH264) { | |
1886 return AllocatedEncoder( | |
1887 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kH264), type, false); | |
1879 } | 1888 } |
1880 | 1889 |
1881 // This shouldn't happen, we should not be trying to create something we don't | 1890 // This shouldn't happen, we should not be trying to create something we don't |
1882 // support. | 1891 // support. |
1883 DCHECK(false); | 1892 DCHECK(false); |
1884 return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false); | 1893 return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false); |
1885 } | 1894 } |
1886 | 1895 |
1887 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( | 1896 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( |
1888 AllocatedEncoder* encoder) { | 1897 AllocatedEncoder* encoder) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2277 if (type == webrtc::kVideoCodecVP8) { | 2286 if (type == webrtc::kVideoCodecVP8) { |
2278 return AllocatedDecoder( | 2287 return AllocatedDecoder( |
2279 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false); | 2288 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false); |
2280 } | 2289 } |
2281 | 2290 |
2282 if (type == webrtc::kVideoCodecVP9) { | 2291 if (type == webrtc::kVideoCodecVP9) { |
2283 return AllocatedDecoder( | 2292 return AllocatedDecoder( |
2284 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp9), type, false); | 2293 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp9), type, false); |
2285 } | 2294 } |
2286 | 2295 |
2296 if (type == webrtc::kVideoCodecH264) { | |
2297 return AllocatedDecoder( | |
2298 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kH264), type, false); | |
2299 } | |
2300 | |
2287 // This shouldn't happen, we should not be trying to create something we don't | 2301 // This shouldn't happen, we should not be trying to create something we don't |
2288 // support. | 2302 // support. |
2289 DCHECK(false); | 2303 DCHECK(false); |
2290 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false); | 2304 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false); |
2291 } | 2305 } |
2292 | 2306 |
2293 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs( | 2307 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs( |
2294 const std::vector<VideoCodecSettings>& recv_codecs) { | 2308 const std::vector<VideoCodecSettings>& recv_codecs) { |
2295 std::vector<AllocatedDecoder> old_decoders = allocated_decoders_; | 2309 std::vector<AllocatedDecoder> old_decoders = allocated_decoders_; |
2296 allocated_decoders_.clear(); | 2310 allocated_decoders_.clear(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2580 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2594 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2581 } | 2595 } |
2582 } | 2596 } |
2583 | 2597 |
2584 return video_codecs; | 2598 return video_codecs; |
2585 } | 2599 } |
2586 | 2600 |
2587 } // namespace cricket | 2601 } // namespace cricket |
2588 | 2602 |
2589 #endif // HAVE_WEBRTC_VIDEO | 2603 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |