blob: 6e6ff062749ba8f6d8cac18ef9484b27ac0df4c1 [file] [log] [blame]
zstein398c3fd2017-07-19 13:38:02 -07001/*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/pc/srtptransport.h"
12
13#include <string>
14
15#include "webrtc/media/base/rtputils.h"
16#include "webrtc/pc/rtptransport.h"
17#include "webrtc/pc/srtpsession.h"
18#include "webrtc/rtc_base/asyncpacketsocket.h"
19#include "webrtc/rtc_base/copyonwritebuffer.h"
20#include "webrtc/rtc_base/ptr_util.h"
21#include "webrtc/rtc_base/trace_event.h"
22
23namespace webrtc {
24
25SrtpTransport::SrtpTransport(bool rtcp_mux_enabled,
26 const std::string& content_name)
27 : content_name_(content_name),
28 rtp_transport_(rtc::MakeUnique<RtpTransport>(rtcp_mux_enabled)) {
29 ConnectToRtpTransport();
30}
31
32SrtpTransport::SrtpTransport(std::unique_ptr<RtpTransportInternal> transport,
33 const std::string& content_name)
34 : content_name_(content_name), rtp_transport_(std::move(transport)) {
35 ConnectToRtpTransport();
36}
37
38void SrtpTransport::ConnectToRtpTransport() {
39 rtp_transport_->SignalPacketReceived.connect(
40 this, &SrtpTransport::OnPacketReceived);
41 rtp_transport_->SignalReadyToSend.connect(this,
42 &SrtpTransport::OnReadyToSend);
43}
44
45bool SrtpTransport::SendPacket(bool rtcp,
46 rtc::CopyOnWriteBuffer* packet,
47 const rtc::PacketOptions& options,
48 int flags) {
49 // TODO(zstein): Protect packet.
50
51 return rtp_transport_->SendPacket(rtcp, packet, options, flags);
52}
53
54void SrtpTransport::OnPacketReceived(bool rtcp,
55 rtc::CopyOnWriteBuffer* packet,
56 const rtc::PacketTime& packet_time) {
57 // TODO(zstein): Unprotect packet.
58
59 SignalPacketReceived(rtcp, packet, packet_time);
60}
61
62} // namespace webrtc