blob: d43acb2c7cd1d59a66aede71cd72f493c0539f60 [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
2 * Copyright (c) 2012 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
12#define MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010013
hbos8d609f62017-04-10 07:39:05 -070014#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/rtpreceiverinterface.h"
17#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018
19namespace webrtc {
20
21class RTPPayloadRegistry;
magjed56124bd2016-11-24 09:34:46 -080022class VideoCodec;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010023
danilchap799a9d02016-09-22 03:36:27 -070024class TelephoneEventHandler {
25 public:
26 virtual ~TelephoneEventHandler() {}
27
28 // The following three methods implement the TelephoneEventHandler interface.
29 // Forward DTMFs to decoder for playout.
30 virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
31
32 // Is forwarding of outband telephone events turned on/off?
33 virtual bool TelephoneEventForwardToDecoder() const = 0;
34
35 // Is TelephoneEvent configured with payload type payload_type
36 virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
37};
38
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010039class RtpReceiver {
40 public:
41 // Creates a video-enabled RTP receiver.
42 static RtpReceiver* CreateVideoReceiver(
43 Clock* clock,
44 RtpData* incoming_payload_callback,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010045 RTPPayloadRegistry* rtp_payload_registry);
46
47 // Creates an audio-enabled RTP receiver.
48 static RtpReceiver* CreateAudioReceiver(
49 Clock* clock,
solenberg1d031392016-03-30 02:42:32 -070050 RtpData* incoming_payload_callback,
solenberg1d031392016-03-30 02:42:32 -070051 RTPPayloadRegistry* rtp_payload_registry);
52
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010053 virtual ~RtpReceiver() {}
54
danilchap799a9d02016-09-22 03:36:27 -070055 // Returns a TelephoneEventHandler if available.
56 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
57
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010058 // Registers a receive payload in the payload registry and notifies the media
59 // receiver strategy.
Karl Wibergc62f6c72017-10-04 12:38:53 +020060 virtual int32_t RegisterReceivePayload(
61 int payload_type,
62 const SdpAudioFormat& audio_format) = 0;
63
64 // Deprecated version of the above.
65 int32_t RegisterReceivePayload(const CodecInst& audio_codec);
66
magjed6b272c52016-11-25 02:29:39 -080067 // Registers a receive payload in the payload registry.
68 virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010069
70 // De-registers |payload_type| from the payload registry.
71 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
72
73 // Parses the media specific parts of an RTP packet and updates the receiver
74 // state. This for instance means that any changes in SSRC and payload type is
75 // detected and acted upon.
76 virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
77 const uint8_t* payload,
78 size_t payload_length,
Niels Möller22ec9522017-10-05 08:39:15 +020079 PayloadUnion payload_specific) = 0;
80 // TODO(nisse): Deprecated version, delete as soon as downstream
81 // applications are updated.
82 bool IncomingRtpPacket(const RTPHeader& rtp_header,
83 const uint8_t* payload,
84 size_t payload_length,
85 PayloadUnion payload_specific,
86 bool in_order /* Ignored */) {
87 return IncomingRtpPacket(rtp_header, payload, payload_length,
88 payload_specific);
89 }
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010090
Niels Möllerc3fa8e12017-10-03 15:28:26 +020091 // Gets the RTP timestamp and the corresponding monotonic system
92 // time for the most recent in-order packet. Returns true on
93 // success, false if no packet has been received.
94 virtual bool GetLatestTimestamps(uint32_t* timestamp,
95 int64_t* receive_time_ms) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010096
97 // Returns the remote SSRC of the currently received RTP stream.
98 virtual uint32_t SSRC() const = 0;
99
100 // Returns the current remote CSRCs.
101 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
102
hbos8d609f62017-04-10 07:39:05 -0700103 virtual std::vector<RtpSource> GetSources() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100104};
105} // namespace webrtc
106
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200107#endif // MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_