| 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 963 |
| 964 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { | 964 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { |
| 965 if (!send_codec_) { | 965 if (!send_codec_) { |
| 966 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; | 966 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; |
| 967 return false; | 967 return false; |
| 968 } | 968 } |
| 969 *codec = send_codec_->codec; | 969 *codec = send_codec_->codec; |
| 970 return true; | 970 return true; |
| 971 } | 971 } |
| 972 | 972 |
| 973 bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc, | |
| 974 const VideoFormat& format) { | |
| 975 LOG(LS_VERBOSE) << "SetSendStreamFormat:" << ssrc << " -> " | |
| 976 << format.ToString(); | |
| 977 rtc::CritScope stream_lock(&stream_crit_); | |
| 978 if (send_streams_.find(ssrc) == send_streams_.end()) { | |
| 979 return false; | |
| 980 } | |
| 981 return send_streams_[ssrc]->SetVideoFormat(format); | |
| 982 } | |
| 983 | |
| 984 bool WebRtcVideoChannel2::SetSend(bool send) { | 973 bool WebRtcVideoChannel2::SetSend(bool send) { |
| 985 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false"); | 974 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false"); |
| 986 if (send && !send_codec_) { | 975 if (send && !send_codec_) { |
| 987 LOG(LS_ERROR) << "SetSend(true) called before setting codec."; | 976 LOG(LS_ERROR) << "SetSend(true) called before setting codec."; |
| 988 return false; | 977 return false; |
| 989 } | 978 } |
| 990 if (send) { | 979 if (send) { |
| 991 StartAllSendStreams(); | 980 StartAllSendStreams(); |
| 992 } else { | 981 } else { |
| 993 StopAllSendStreams(); | 982 StopAllSendStreams(); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 } | 1674 } |
| 1686 | 1675 |
| 1687 capturer_ = capturer; | 1676 capturer_ = capturer; |
| 1688 } | 1677 } |
| 1689 // Lock cannot be held while connecting the capturer to prevent lock-order | 1678 // Lock cannot be held while connecting the capturer to prevent lock-order |
| 1690 // violations. | 1679 // violations. |
| 1691 capturer->SignalVideoFrame.connect(this, &WebRtcVideoSendStream::InputFrame); | 1680 capturer->SignalVideoFrame.connect(this, &WebRtcVideoSendStream::InputFrame); |
| 1692 return true; | 1681 return true; |
| 1693 } | 1682 } |
| 1694 | 1683 |
| 1695 // TODO(pbos): Apply this on the VideoAdapter instead! | |
| 1696 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoFormat( | |
| 1697 const VideoFormat& format) { | |
| 1698 if ((format.width == 0 || format.height == 0) && | |
| 1699 format.width != format.height) { | |
| 1700 LOG(LS_ERROR) << "Can't set VideoFormat, width or height is zero (but not " | |
| 1701 "both, 0x0 drops frames)."; | |
| 1702 return false; | |
| 1703 } | |
| 1704 | |
| 1705 rtc::CritScope cs(&lock_); | |
| 1706 if (format.width == 0 && format.height == 0) { | |
| 1707 LOG(LS_INFO) | |
| 1708 << "0x0 resolution selected. Captured frames will be dropped for ssrc: " | |
| 1709 << parameters_.config.rtp.ssrcs[0] << "."; | |
| 1710 } else { | |
| 1711 // TODO(pbos): Fix me, this only affects the last stream! | |
| 1712 parameters_.encoder_config.streams.back().max_framerate = | |
| 1713 VideoFormat::IntervalToFps(format.interval); | |
| 1714 SetDimensions(format.width, format.height, false); | |
| 1715 } | |
| 1716 | |
| 1717 format_ = format; | |
| 1718 return true; | |
| 1719 } | |
| 1720 | |
| 1721 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { | 1684 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { |
| 1722 rtc::CritScope cs(&lock_); | 1685 rtc::CritScope cs(&lock_); |
| 1723 muted_ = mute; | 1686 muted_ = mute; |
| 1724 } | 1687 } |
| 1725 | 1688 |
| 1726 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { | 1689 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { |
| 1727 cricket::VideoCapturer* capturer; | 1690 cricket::VideoCapturer* capturer; |
| 1728 { | 1691 { |
| 1729 rtc::CritScope cs(&lock_); | 1692 rtc::CritScope cs(&lock_); |
| 1730 if (capturer_ == NULL) | 1693 if (capturer_ == NULL) |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2548 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2586 } | 2549 } |
| 2587 } | 2550 } |
| 2588 | 2551 |
| 2589 return video_codecs; | 2552 return video_codecs; |
| 2590 } | 2553 } |
| 2591 | 2554 |
| 2592 } // namespace cricket | 2555 } // namespace cricket |
| 2593 | 2556 |
| 2594 #endif // HAVE_WEBRTC_VIDEO | 2557 #endif // HAVE_WEBRTC_VIDEO |
| OLD | NEW |