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 28 matching lines...) Expand all Loading... | |
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 Loading... | |
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(¶meters_.config.rtp.ssrcs); | 1672 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
1670 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1673 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1671 ¶meters_.config.rtp.rtx.ssrcs); | 1674 ¶meters_.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(¶ms)) { | 1679 if (codec_settings.Get(¶ms)) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; | |
1741 video_frame.set_render_time_ms(last_timestamp_ms_); | |
pthatcher1
2015/07/14 17:57:28
I think this would be more clear if you put "frame
qiangchen
2015/07/14 22:04:26
Done.
| |
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 // Force this black frame not to be dropped due to timestamp order | |
1772 // check. | |
pthatcher1
2015/07/14 17:57:28
Can you explain a little more how adding "+ 1" acc
qiangchen
2015/07/14 22:04:26
Done. Add 1 could bypass the timestamp check in In
| |
1773 black_frame.set_render_time_ms(last_timestamp_ms_ + 1); | |
1758 stream_->Input()->IncomingCapturedFrame(black_frame); | 1774 stream_->Input()->IncomingCapturedFrame(black_frame); |
1759 } | 1775 } |
1760 | 1776 |
1761 capturer_ = NULL; | 1777 capturer_ = NULL; |
1762 return true; | 1778 return true; |
1763 } | 1779 } |
1764 | 1780 |
1765 capturer_ = capturer; | 1781 capturer_ = capturer; |
1766 } | 1782 } |
1767 // Lock cannot be held while connecting the capturer to prevent lock-order | 1783 // Lock cannot be held while connecting the capturer to prevent lock-order |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2595 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2611 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2596 } | 2612 } |
2597 } | 2613 } |
2598 | 2614 |
2599 return video_codecs; | 2615 return video_codecs; |
2600 } | 2616 } |
2601 | 2617 |
2602 } // namespace cricket | 2618 } // namespace cricket |
2603 | 2619 |
2604 #endif // HAVE_WEBRTC_VIDEO | 2620 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |