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

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

Issue 1225153002: Let WebRtcVideoChannel2::WebRtcVideoSendStream::InputFrame carry the input frame's timestamp to out… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Black frame timestamp 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 28 matching lines...) Expand all
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/h264/include/h264.h"
47 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" 47 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
48 #include "webrtc/system_wrappers/interface/field_trial.h" 48 #include "webrtc/system_wrappers/interface/field_trial.h"
49 #include "webrtc/system_wrappers/interface/tick_util.h"
49 #include "webrtc/system_wrappers/interface/trace_event.h" 50 #include "webrtc/system_wrappers/interface/trace_event.h"
50 #include "webrtc/video_decoder.h" 51 #include "webrtc/video_decoder.h"
51 #include "webrtc/video_encoder.h" 52 #include "webrtc/video_encoder.h"
52 53
53 #define UNIMPLEMENTED \ 54 #define UNIMPLEMENTED \
54 LOG(LS_ERROR) << "Call to unimplemented function " << __FUNCTION__; \ 55 LOG(LS_ERROR) << "Call to unimplemented function " << __FUNCTION__; \
55 RTC_NOTREACHED() 56 RTC_NOTREACHED()
56 57
57 namespace cricket { 58 namespace cricket {
58 namespace { 59 namespace {
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 external_encoder_factory_(external_encoder_factory), 1657 external_encoder_factory_(external_encoder_factory),
1657 stream_(NULL), 1658 stream_(NULL),
1658 parameters_(webrtc::VideoSendStream::Config(), 1659 parameters_(webrtc::VideoSendStream::Config(),
1659 options, 1660 options,
1660 max_bitrate_bps, 1661 max_bitrate_bps,
1661 codec_settings), 1662 codec_settings),
1662 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), 1663 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false),
1663 capturer_(NULL), 1664 capturer_(NULL),
1664 sending_(false), 1665 sending_(false),
1665 muted_(false), 1666 muted_(false),
1666 old_adapt_changes_(0) { 1667 old_adapt_changes_(0),
1668 base_timestamp_ms_(0),
1669 last_timestamp_ms_(0) {
1667 parameters_.config.rtp.max_packet_size = kVideoMtu; 1670 parameters_.config.rtp.max_packet_size = kVideoMtu;
1668 1671
1669 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1672 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1670 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1673 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1671 &parameters_.config.rtp.rtx.ssrcs); 1674 &parameters_.config.rtp.rtx.ssrcs);
1672 parameters_.config.rtp.c_name = sp.cname; 1675 parameters_.config.rtp.c_name = sp.cname;
1673 parameters_.config.rtp.extensions = rtp_extensions; 1676 parameters_.config.rtp.extensions = rtp_extensions;
1674 1677
1675 VideoCodecSettings params; 1678 VideoCodecSettings params;
1676 if (codec_settings.Get(&params)) { 1679 if (codec_settings.Get(&params)) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 DCHECK(format_.height == 0); 1723 DCHECK(format_.height == 0);
1721 LOG(LS_VERBOSE) << "VideoFormat 0x0 set, Dropping frame."; 1724 LOG(LS_VERBOSE) << "VideoFormat 0x0 set, Dropping frame.";
1722 return; 1725 return;
1723 } 1726 }
1724 if (muted_) { 1727 if (muted_) {
1725 // Create a black frame to transmit instead. 1728 // Create a black frame to transmit instead.
1726 CreateBlackFrame(&video_frame, 1729 CreateBlackFrame(&video_frame,
1727 static_cast<int>(frame->GetWidth()), 1730 static_cast<int>(frame->GetWidth()),
1728 static_cast<int>(frame->GetHeight())); 1731 static_cast<int>(frame->GetHeight()));
1729 } 1732 }
1733
1734 // frame->GetTimeStamp() is essentially a delta, align to webrtc time
1735 if (base_timestamp_ms_ == 0) {
1736 base_timestamp_ms_ = webrtc::TickTime::MillisecondTimestamp() -
1737 frame->GetTimeStamp() / 1000000;
1738 }
1739
1740 last_timestamp_ms_=base_timestamp_ms_ + frame->GetTimeStamp() / 1000000;
pbos-webrtc 2015/07/14 04:13:14 style (= -> " = "), run git cl format.
1741 video_frame.set_render_time_ms(last_timestamp_ms_);
1730 // Reconfigure codec if necessary. 1742 // Reconfigure codec if necessary.
1731 SetDimensions( 1743 SetDimensions(
1732 video_frame.width(), video_frame.height(), capturer->IsScreencast()); 1744 video_frame.width(), video_frame.height(), capturer->IsScreencast());
1733 1745
1734 LOG(LS_VERBOSE) << "IncomingCapturedFrame: " << video_frame.width() << "x" 1746 LOG(LS_VERBOSE) << "IncomingCapturedFrame: " << video_frame.width() << "x"
1735 << video_frame.height() << " -> (codec) " 1747 << video_frame.height() << " -> (codec) "
1736 << parameters_.encoder_config.streams.back().width << "x" 1748 << parameters_.encoder_config.streams.back().width << "x"
1737 << parameters_.encoder_config.streams.back().height; 1749 << parameters_.encoder_config.streams.back().height;
1738 stream_->Input()->IncomingCapturedFrame(video_frame); 1750 stream_->Input()->IncomingCapturedFrame(video_frame);
1739 } 1751 }
1740 1752
1741 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( 1753 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer(
1742 VideoCapturer* capturer) { 1754 VideoCapturer* capturer) {
1743 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); 1755 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer");
1744 if (!DisconnectCapturer() && capturer == NULL) { 1756 if (!DisconnectCapturer() && capturer == NULL) {
1745 return false; 1757 return false;
1746 } 1758 }
1747 1759
1748 { 1760 {
1749 rtc::CritScope cs(&lock_); 1761 rtc::CritScope cs(&lock_);
1750 1762
1751 if (capturer == NULL) { 1763 if (capturer == NULL) {
1752 if (stream_ != NULL) { 1764 if (stream_ != NULL) {
1753 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; 1765 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame.";
1754 webrtc::VideoFrame black_frame; 1766 webrtc::VideoFrame black_frame;
1755 1767
1756 CreateBlackFrame(&black_frame, last_dimensions_.width, 1768 CreateBlackFrame(&black_frame, last_dimensions_.width,
1757 last_dimensions_.height); 1769 last_dimensions_.height);
1770
1771 black_frame.set_render_time_ms(last_timestamp_ms_ + 1);
pbos-webrtc 2015/07/14 04:13:14 Add a comment here, I think.
1758 stream_->Input()->IncomingCapturedFrame(black_frame); 1772 stream_->Input()->IncomingCapturedFrame(black_frame);
1759 } 1773 }
1760 1774
1761 capturer_ = NULL; 1775 capturer_ = NULL;
1762 return true; 1776 return true;
1763 } 1777 }
1764 1778
1765 capturer_ = capturer; 1779 capturer_ = capturer;
1766 } 1780 }
1767 // Lock cannot be held while connecting the capturer to prevent lock-order 1781 // Lock cannot be held while connecting the capturer to prevent lock-order
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2609 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2596 } 2610 }
2597 } 2611 }
2598 2612
2599 return video_codecs; 2613 return video_codecs;
2600 } 2614 }
2601 2615
2602 } // namespace cricket 2616 } // namespace cricket
2603 2617
2604 #endif // HAVE_WEBRTC_VIDEO 2618 #endif // HAVE_WEBRTC_VIDEO
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/media/webrtc/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698