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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 return true; | 1178 return true; |
1179 } | 1179 } |
1180 | 1180 |
1181 rtc::CritScope stream_lock(&stream_crit_); | 1181 rtc::CritScope stream_lock(&stream_crit_); |
1182 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | 1182 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = |
1183 receive_streams_.find(ssrc); | 1183 receive_streams_.find(ssrc); |
1184 if (it == receive_streams_.end()) { | 1184 if (it == receive_streams_.end()) { |
1185 return false; | 1185 return false; |
1186 } | 1186 } |
1187 | 1187 |
1188 it->second->SetSink(renderer); | 1188 it->second->SetRenderer(renderer); |
1189 return true; | 1189 return true; |
1190 } | 1190 } |
1191 | 1191 |
1192 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { | 1192 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { |
1193 info->Clear(); | 1193 info->Clear(); |
1194 FillSenderStats(info); | 1194 FillSenderStats(info); |
1195 FillReceiverStats(info); | 1195 FillReceiverStats(info); |
1196 webrtc::Call::Stats stats = call_->GetStats(); | 1196 webrtc::Call::Stats stats = call_->GetStats(); |
1197 FillBandwidthEstimationStats(stats, info); | 1197 FillBandwidthEstimationStats(stats, info); |
1198 if (stats.rtt_ms != -1) { | 1198 if (stats.rtt_ms != -1) { |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 const std::vector<VideoCodecSettings>& recv_codecs, | 2224 const std::vector<VideoCodecSettings>& recv_codecs, |
2225 bool disable_prerenderer_smoothing) | 2225 bool disable_prerenderer_smoothing) |
2226 : call_(call), | 2226 : call_(call), |
2227 ssrcs_(sp.ssrcs), | 2227 ssrcs_(sp.ssrcs), |
2228 ssrc_groups_(sp.ssrc_groups), | 2228 ssrc_groups_(sp.ssrc_groups), |
2229 stream_(NULL), | 2229 stream_(NULL), |
2230 default_stream_(default_stream), | 2230 default_stream_(default_stream), |
2231 config_(config), | 2231 config_(config), |
2232 external_decoder_factory_(external_decoder_factory), | 2232 external_decoder_factory_(external_decoder_factory), |
2233 disable_prerenderer_smoothing_(disable_prerenderer_smoothing), | 2233 disable_prerenderer_smoothing_(disable_prerenderer_smoothing), |
2234 sink_(NULL), | 2234 renderer_(NULL), |
2235 last_width_(-1), | 2235 last_width_(-1), |
2236 last_height_(-1), | 2236 last_height_(-1), |
2237 first_frame_timestamp_(-1), | 2237 first_frame_timestamp_(-1), |
2238 estimated_remote_start_ntp_time_ms_(0) { | 2238 estimated_remote_start_ntp_time_ms_(0) { |
2239 config_.renderer = this; | 2239 config_.renderer = this; |
2240 // SetRecvCodecs will also reset (start) the VideoReceiveStream. | 2240 // SetRecvCodecs will also reset (start) the VideoReceiveStream. |
2241 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive " | 2241 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive " |
2242 "stream for the first time: " | 2242 "stream for the first time: " |
2243 << CodecSettingsVectorToString(recv_codecs); | 2243 << CodecSettingsVectorToString(recv_codecs); |
2244 SetRecvCodecs(recv_codecs); | 2244 SetRecvCodecs(recv_codecs); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 (*allocated_decoders)[i].external_decoder); | 2417 (*allocated_decoders)[i].external_decoder); |
2418 } | 2418 } |
2419 delete (*allocated_decoders)[i].decoder; | 2419 delete (*allocated_decoders)[i].decoder; |
2420 } | 2420 } |
2421 allocated_decoders->clear(); | 2421 allocated_decoders->clear(); |
2422 } | 2422 } |
2423 | 2423 |
2424 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RenderFrame( | 2424 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RenderFrame( |
2425 const webrtc::VideoFrame& frame, | 2425 const webrtc::VideoFrame& frame, |
2426 int time_to_render_ms) { | 2426 int time_to_render_ms) { |
2427 rtc::CritScope crit(&sink_lock_); | 2427 rtc::CritScope crit(&renderer_lock_); |
2428 | 2428 |
2429 if (first_frame_timestamp_ < 0) | 2429 if (first_frame_timestamp_ < 0) |
2430 first_frame_timestamp_ = frame.timestamp(); | 2430 first_frame_timestamp_ = frame.timestamp(); |
2431 int64_t rtp_time_elapsed_since_first_frame = | 2431 int64_t rtp_time_elapsed_since_first_frame = |
2432 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) - | 2432 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) - |
2433 first_frame_timestamp_); | 2433 first_frame_timestamp_); |
2434 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / | 2434 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / |
2435 (cricket::kVideoCodecClockrate / 1000); | 2435 (cricket::kVideoCodecClockrate / 1000); |
2436 if (frame.ntp_time_ms() > 0) | 2436 if (frame.ntp_time_ms() > 0) |
2437 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; | 2437 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; |
2438 | 2438 |
2439 if (sink_ == NULL) { | 2439 if (renderer_ == NULL) { |
2440 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; | 2440 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoRenderer."; |
2441 return; | 2441 return; |
2442 } | 2442 } |
2443 | 2443 |
2444 last_width_ = frame.width(); | 2444 last_width_ = frame.width(); |
2445 last_height_ = frame.height(); | 2445 last_height_ = frame.height(); |
2446 | 2446 |
2447 const WebRtcVideoFrame render_frame( | 2447 const WebRtcVideoFrame render_frame( |
2448 frame.video_frame_buffer(), | 2448 frame.video_frame_buffer(), |
2449 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); | 2449 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); |
2450 sink_->OnFrame(render_frame); | 2450 renderer_->RenderFrame(&render_frame); |
2451 } | 2451 } |
2452 | 2452 |
2453 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const { | 2453 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const { |
2454 return true; | 2454 return true; |
2455 } | 2455 } |
2456 | 2456 |
2457 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames() | 2457 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames() |
2458 const { | 2458 const { |
2459 return disable_prerenderer_smoothing_; | 2459 return disable_prerenderer_smoothing_; |
2460 } | 2460 } |
2461 | 2461 |
2462 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { | 2462 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { |
2463 return default_stream_; | 2463 return default_stream_; |
2464 } | 2464 } |
2465 | 2465 |
2466 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( | 2466 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRenderer( |
2467 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { | 2467 cricket::VideoRenderer* renderer) { |
2468 rtc::CritScope crit(&sink_lock_); | 2468 rtc::CritScope crit(&renderer_lock_); |
2469 sink_ = sink; | 2469 renderer_ = renderer; |
2470 } | 2470 } |
2471 | 2471 |
2472 std::string | 2472 std::string |
2473 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( | 2473 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( |
2474 int payload_type) { | 2474 int payload_type) { |
2475 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { | 2475 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { |
2476 if (decoder.payload_type == payload_type) { | 2476 if (decoder.payload_type == payload_type) { |
2477 return decoder.payload_name; | 2477 return decoder.payload_name; |
2478 } | 2478 } |
2479 } | 2479 } |
(...skipping 13 matching lines...) Expand all Loading... |
2493 info.packets_rcvd = stats.rtp_stats.transmitted.packets; | 2493 info.packets_rcvd = stats.rtp_stats.transmitted.packets; |
2494 info.packets_lost = stats.rtcp_stats.cumulative_lost; | 2494 info.packets_lost = stats.rtcp_stats.cumulative_lost; |
2495 info.fraction_lost = | 2495 info.fraction_lost = |
2496 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8); | 2496 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8); |
2497 | 2497 |
2498 info.framerate_rcvd = stats.network_frame_rate; | 2498 info.framerate_rcvd = stats.network_frame_rate; |
2499 info.framerate_decoded = stats.decode_frame_rate; | 2499 info.framerate_decoded = stats.decode_frame_rate; |
2500 info.framerate_output = stats.render_frame_rate; | 2500 info.framerate_output = stats.render_frame_rate; |
2501 | 2501 |
2502 { | 2502 { |
2503 rtc::CritScope frame_cs(&sink_lock_); | 2503 rtc::CritScope frame_cs(&renderer_lock_); |
2504 info.frame_width = last_width_; | 2504 info.frame_width = last_width_; |
2505 info.frame_height = last_height_; | 2505 info.frame_height = last_height_; |
2506 info.capture_start_ntp_time_ms = estimated_remote_start_ntp_time_ms_; | 2506 info.capture_start_ntp_time_ms = estimated_remote_start_ntp_time_ms_; |
2507 } | 2507 } |
2508 | 2508 |
2509 info.decode_ms = stats.decode_ms; | 2509 info.decode_ms = stats.decode_ms; |
2510 info.max_decode_ms = stats.max_decode_ms; | 2510 info.max_decode_ms = stats.max_decode_ms; |
2511 info.current_delay_ms = stats.current_delay_ms; | 2511 info.current_delay_ms = stats.current_delay_ms; |
2512 info.target_delay_ms = stats.target_delay_ms; | 2512 info.target_delay_ms = stats.target_delay_ms; |
2513 info.jitter_buffer_ms = stats.jitter_buffer_ms; | 2513 info.jitter_buffer_ms = stats.jitter_buffer_ms; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2631 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2631 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2632 } | 2632 } |
2633 } | 2633 } |
2634 | 2634 |
2635 return video_codecs; | 2635 return video_codecs; |
2636 } | 2636 } |
2637 | 2637 |
2638 } // namespace cricket | 2638 } // namespace cricket |
2639 | 2639 |
2640 #endif // HAVE_WEBRTC_VIDEO | 2640 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |