| 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 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / | 2445 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / |
| 2446 (cricket::kVideoCodecClockrate / 1000); | 2446 (cricket::kVideoCodecClockrate / 1000); |
| 2447 if (frame.ntp_time_ms() > 0) | 2447 if (frame.ntp_time_ms() > 0) |
| 2448 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; | 2448 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; |
| 2449 | 2449 |
| 2450 if (renderer_ == NULL) { | 2450 if (renderer_ == NULL) { |
| 2451 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoRenderer."; | 2451 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoRenderer."; |
| 2452 return; | 2452 return; |
| 2453 } | 2453 } |
| 2454 | 2454 |
| 2455 if (frame.width() != last_width_ || frame.height() != last_height_) { | 2455 last_width_ = frame.width(); |
| 2456 SetSize(frame.width(), frame.height()); | 2456 last_height_ = frame.height(); |
| 2457 } | |
| 2458 | 2457 |
| 2459 const WebRtcVideoFrame render_frame( | 2458 const WebRtcVideoFrame render_frame( |
| 2460 frame.video_frame_buffer(), | 2459 frame.video_frame_buffer(), |
| 2461 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); | 2460 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); |
| 2462 renderer_->RenderFrame(&render_frame); | 2461 renderer_->RenderFrame(&render_frame); |
| 2463 } | 2462 } |
| 2464 | 2463 |
| 2465 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const { | 2464 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const { |
| 2466 return true; | 2465 return true; |
| 2467 } | 2466 } |
| 2468 | 2467 |
| 2469 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames() | 2468 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames() |
| 2470 const { | 2469 const { |
| 2471 return disable_prerenderer_smoothing_; | 2470 return disable_prerenderer_smoothing_; |
| 2472 } | 2471 } |
| 2473 | 2472 |
| 2474 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { | 2473 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { |
| 2475 return default_stream_; | 2474 return default_stream_; |
| 2476 } | 2475 } |
| 2477 | 2476 |
| 2478 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRenderer( | 2477 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRenderer( |
| 2479 cricket::VideoRenderer* renderer) { | 2478 cricket::VideoRenderer* renderer) { |
| 2480 rtc::CritScope crit(&renderer_lock_); | 2479 rtc::CritScope crit(&renderer_lock_); |
| 2481 renderer_ = renderer; | 2480 renderer_ = renderer; |
| 2482 if (renderer_ != NULL && last_width_ != -1) { | |
| 2483 SetSize(last_width_, last_height_); | |
| 2484 } | |
| 2485 } | 2481 } |
| 2486 | 2482 |
| 2487 VideoRenderer* WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetRenderer() { | 2483 VideoRenderer* WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetRenderer() { |
| 2488 // TODO(pbos): Remove GetRenderer and all uses of it, it's thread-unsafe by | 2484 // TODO(pbos): Remove GetRenderer and all uses of it, it's thread-unsafe by |
| 2489 // design. | 2485 // design. |
| 2490 rtc::CritScope crit(&renderer_lock_); | 2486 rtc::CritScope crit(&renderer_lock_); |
| 2491 return renderer_; | 2487 return renderer_; |
| 2492 } | 2488 } |
| 2493 | 2489 |
| 2494 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSize(int width, | |
| 2495 int height) { | |
| 2496 rtc::CritScope crit(&renderer_lock_); | |
| 2497 if (!renderer_->SetSize(width, height, 0)) { | |
| 2498 LOG(LS_ERROR) << "Could not set renderer size."; | |
| 2499 } | |
| 2500 last_width_ = width; | |
| 2501 last_height_ = height; | |
| 2502 } | |
| 2503 | |
| 2504 std::string | 2490 std::string |
| 2505 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( | 2491 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( |
| 2506 int payload_type) { | 2492 int payload_type) { |
| 2507 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { | 2493 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { |
| 2508 if (decoder.payload_type == payload_type) { | 2494 if (decoder.payload_type == payload_type) { |
| 2509 return decoder.payload_name; | 2495 return decoder.payload_name; |
| 2510 } | 2496 } |
| 2511 } | 2497 } |
| 2512 return ""; | 2498 return ""; |
| 2513 } | 2499 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2663 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2649 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2664 } | 2650 } |
| 2665 } | 2651 } |
| 2666 | 2652 |
| 2667 return video_codecs; | 2653 return video_codecs; |
| 2668 } | 2654 } |
| 2669 | 2655 |
| 2670 } // namespace cricket | 2656 } // namespace cricket |
| 2671 | 2657 |
| 2672 #endif // HAVE_WEBRTC_VIDEO | 2658 #endif // HAVE_WEBRTC_VIDEO |
| OLD | NEW |