OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream " | 912 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream " |
913 << "with ssrc " << ssrc << " which doesn't exist."; | 913 << "with ssrc " << ssrc << " which doesn't exist."; |
914 return webrtc::RtpParameters(); | 914 return webrtc::RtpParameters(); |
915 } | 915 } |
916 | 916 |
917 // TODO(deadbeef): Return stream-specific parameters. | 917 // TODO(deadbeef): Return stream-specific parameters. |
918 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding(); | 918 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding(); |
919 for (const VideoCodec& codec : recv_params_.codecs) { | 919 for (const VideoCodec& codec : recv_params_.codecs) { |
920 rtp_params.codecs.push_back(codec.ToCodecParameters()); | 920 rtp_params.codecs.push_back(codec.ToCodecParameters()); |
921 } | 921 } |
| 922 rtp_params.encodings[0].ssrc = it->second->GetFirstPrimarySsrc(); |
922 return rtp_params; | 923 return rtp_params; |
923 } | 924 } |
924 | 925 |
925 bool WebRtcVideoChannel2::SetRtpReceiveParameters( | 926 bool WebRtcVideoChannel2::SetRtpReceiveParameters( |
926 uint32_t ssrc, | 927 uint32_t ssrc, |
927 const webrtc::RtpParameters& parameters) { | 928 const webrtc::RtpParameters& parameters) { |
928 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRtpReceiveParameters"); | 929 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRtpReceiveParameters"); |
929 rtc::CritScope stream_lock(&stream_crit_); | 930 rtc::CritScope stream_lock(&stream_crit_); |
930 auto it = receive_streams_.find(ssrc); | 931 auto it = receive_streams_.find(ssrc); |
931 if (it == receive_streams_.end()) { | 932 if (it == receive_streams_.end()) { |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 | 2200 |
2200 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2201 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
2201 webrtc::Call* call, | 2202 webrtc::Call* call, |
2202 const StreamParams& sp, | 2203 const StreamParams& sp, |
2203 webrtc::VideoReceiveStream::Config config, | 2204 webrtc::VideoReceiveStream::Config config, |
2204 WebRtcVideoDecoderFactory* external_decoder_factory, | 2205 WebRtcVideoDecoderFactory* external_decoder_factory, |
2205 bool default_stream, | 2206 bool default_stream, |
2206 const std::vector<VideoCodecSettings>& recv_codecs, | 2207 const std::vector<VideoCodecSettings>& recv_codecs, |
2207 bool red_disabled_by_remote_side) | 2208 bool red_disabled_by_remote_side) |
2208 : call_(call), | 2209 : call_(call), |
2209 ssrcs_(sp.ssrcs), | 2210 stream_params_(sp), |
2210 ssrc_groups_(sp.ssrc_groups), | |
2211 stream_(NULL), | 2211 stream_(NULL), |
2212 default_stream_(default_stream), | 2212 default_stream_(default_stream), |
2213 config_(std::move(config)), | 2213 config_(std::move(config)), |
2214 red_disabled_by_remote_side_(red_disabled_by_remote_side), | 2214 red_disabled_by_remote_side_(red_disabled_by_remote_side), |
2215 external_decoder_factory_(external_decoder_factory), | 2215 external_decoder_factory_(external_decoder_factory), |
2216 sink_(NULL), | 2216 sink_(NULL), |
2217 last_width_(-1), | 2217 last_width_(-1), |
2218 last_height_(-1), | 2218 last_height_(-1), |
2219 first_frame_timestamp_(-1), | 2219 first_frame_timestamp_(-1), |
2220 estimated_remote_start_ntp_time_ms_(0) { | 2220 estimated_remote_start_ntp_time_ms_(0) { |
(...skipping 19 matching lines...) Expand all Loading... |
2240 } | 2240 } |
2241 } | 2241 } |
2242 | 2242 |
2243 WebRtcVideoChannel2::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() { | 2243 WebRtcVideoChannel2::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() { |
2244 call_->DestroyVideoReceiveStream(stream_); | 2244 call_->DestroyVideoReceiveStream(stream_); |
2245 ClearDecoders(&allocated_decoders_); | 2245 ClearDecoders(&allocated_decoders_); |
2246 } | 2246 } |
2247 | 2247 |
2248 const std::vector<uint32_t>& | 2248 const std::vector<uint32_t>& |
2249 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetSsrcs() const { | 2249 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetSsrcs() const { |
2250 return ssrcs_; | 2250 return stream_params_.ssrcs; |
| 2251 } |
| 2252 |
| 2253 rtc::Optional<uint32_t> |
| 2254 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetFirstPrimarySsrc() const { |
| 2255 std::vector<uint32_t> primary_ssrcs; |
| 2256 stream_params_.GetPrimarySsrcs(&primary_ssrcs); |
| 2257 |
| 2258 if (primary_ssrcs.empty()) { |
| 2259 LOG(LS_WARNING) << "Empty primary ssrcs vector, returning empty optional"; |
| 2260 return rtc::Optional<uint32_t>(); |
| 2261 } else { |
| 2262 return rtc::Optional<uint32_t>(primary_ssrcs[0]); |
| 2263 } |
2251 } | 2264 } |
2252 | 2265 |
2253 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder | 2266 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder |
2254 WebRtcVideoChannel2::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder( | 2267 WebRtcVideoChannel2::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder( |
2255 std::vector<AllocatedDecoder>* old_decoders, | 2268 std::vector<AllocatedDecoder>* old_decoders, |
2256 const VideoCodec& codec) { | 2269 const VideoCodec& codec) { |
2257 webrtc::VideoCodecType type = CodecTypeFromName(codec.name); | 2270 webrtc::VideoCodecType type = CodecTypeFromName(codec.name); |
2258 | 2271 |
2259 for (size_t i = 0; i < old_decoders->size(); ++i) { | 2272 for (size_t i = 0; i < old_decoders->size(); ++i) { |
2260 if ((*old_decoders)[i].type == type) { | 2273 if ((*old_decoders)[i].type == type) { |
2261 AllocatedDecoder decoder = (*old_decoders)[i]; | 2274 AllocatedDecoder decoder = (*old_decoders)[i]; |
2262 (*old_decoders)[i] = old_decoders->back(); | 2275 (*old_decoders)[i] = old_decoders->back(); |
2263 old_decoders->pop_back(); | 2276 old_decoders->pop_back(); |
2264 return decoder; | 2277 return decoder; |
2265 } | 2278 } |
2266 } | 2279 } |
2267 | 2280 |
2268 if (external_decoder_factory_ != NULL) { | 2281 if (external_decoder_factory_ != NULL) { |
2269 webrtc::VideoDecoder* decoder = | 2282 webrtc::VideoDecoder* decoder = |
2270 external_decoder_factory_->CreateVideoDecoder(type); | 2283 external_decoder_factory_->CreateVideoDecoderWithParams( |
| 2284 type, {stream_params_.id}); |
2271 if (decoder != NULL) { | 2285 if (decoder != NULL) { |
2272 return AllocatedDecoder(decoder, type, true); | 2286 return AllocatedDecoder(decoder, type, true); |
2273 } | 2287 } |
2274 } | 2288 } |
2275 | 2289 |
2276 if (type == webrtc::kVideoCodecVP8) { | 2290 if (type == webrtc::kVideoCodecVP8) { |
2277 return AllocatedDecoder( | 2291 return AllocatedDecoder( |
2278 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false); | 2292 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false); |
2279 } | 2293 } |
2280 | 2294 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2454 if (decoder.payload_type == payload_type) { | 2468 if (decoder.payload_type == payload_type) { |
2455 return decoder.payload_name; | 2469 return decoder.payload_name; |
2456 } | 2470 } |
2457 } | 2471 } |
2458 return ""; | 2472 return ""; |
2459 } | 2473 } |
2460 | 2474 |
2461 VideoReceiverInfo | 2475 VideoReceiverInfo |
2462 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo() { | 2476 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo() { |
2463 VideoReceiverInfo info; | 2477 VideoReceiverInfo info; |
2464 info.ssrc_groups = ssrc_groups_; | 2478 info.ssrc_groups = stream_params_.ssrc_groups; |
2465 info.add_ssrc(config_.rtp.remote_ssrc); | 2479 info.add_ssrc(config_.rtp.remote_ssrc); |
2466 webrtc::VideoReceiveStream::Stats stats = stream_->GetStats(); | 2480 webrtc::VideoReceiveStream::Stats stats = stream_->GetStats(); |
2467 info.decoder_implementation_name = stats.decoder_implementation_name; | 2481 info.decoder_implementation_name = stats.decoder_implementation_name; |
2468 info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes + | 2482 info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes + |
2469 stats.rtp_stats.transmitted.header_bytes + | 2483 stats.rtp_stats.transmitted.header_bytes + |
2470 stats.rtp_stats.transmitted.padding_bytes; | 2484 stats.rtp_stats.transmitted.padding_bytes; |
2471 info.packets_rcvd = stats.rtp_stats.transmitted.packets; | 2485 info.packets_rcvd = stats.rtp_stats.transmitted.packets; |
2472 info.packets_lost = stats.rtcp_stats.cumulative_lost; | 2486 info.packets_lost = stats.rtcp_stats.cumulative_lost; |
2473 info.fraction_lost = | 2487 info.fraction_lost = |
2474 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8); | 2488 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 rtx_mapping[video_codecs[i].codec.id] != | 2627 rtx_mapping[video_codecs[i].codec.id] != |
2614 fec_settings.red_payload_type) { | 2628 fec_settings.red_payload_type) { |
2615 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2629 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2616 } | 2630 } |
2617 } | 2631 } |
2618 | 2632 |
2619 return video_codecs; | 2633 return video_codecs; |
2620 } | 2634 } |
2621 | 2635 |
2622 } // namespace cricket | 2636 } // namespace cricket |
OLD | NEW |