blob: 8607d935a232be6364327ad0af4d966280ec65c4 [file] [log] [blame]
deadbeef6979b022015-09-24 16:47:53 -07001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
deadbeef6979b022015-09-24 16:47:53 -07003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.
deadbeef6979b022015-09-24 16:47:53 -07009 */
10
deadbeef70ab1a12015-09-28 16:53:55 -070011// This file contains interfaces for RtpReceivers
12// http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface
13
Henrik Kjellander15583c12016-02-10 10:53:12 +010014#ifndef WEBRTC_API_RTPRECEIVERINTERFACE_H_
15#define WEBRTC_API_RTPRECEIVERINTERFACE_H_
deadbeef70ab1a12015-09-28 16:53:55 -070016
17#include <string>
18
ossu7bb87ee2017-01-23 04:56:25 -080019#include "webrtc/api/mediatypes.h"
Henrik Kjellander15583c12016-02-10 10:53:12 +010020#include "webrtc/api/mediastreaminterface.h"
21#include "webrtc/api/proxy.h"
Taylor Brandstetterba29c6a2016-06-27 16:30:35 -070022#include "webrtc/api/rtpparameters.h"
deadbeef70ab1a12015-09-28 16:53:55 -070023#include "webrtc/base/refcount.h"
24#include "webrtc/base/scoped_ref_ptr.h"
25
26namespace webrtc {
27
zhihuang184a3fd2016-06-14 11:47:14 -070028class RtpReceiverObserverInterface {
29 public:
Taylor Brandstetterba29c6a2016-06-27 16:30:35 -070030 // Note: Currently if there are multiple RtpReceivers of the same media type,
31 // they will all call OnFirstPacketReceived at once.
32 //
33 // In the future, it's likely that an RtpReceiver will only call
34 // OnFirstPacketReceived when a packet is received specifically for its
35 // SSRC/mid.
zhihuang184a3fd2016-06-14 11:47:14 -070036 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0;
37
38 protected:
39 virtual ~RtpReceiverObserverInterface() {}
40};
41
deadbeef70ab1a12015-09-28 16:53:55 -070042class RtpReceiverInterface : public rtc::RefCountInterface {
43 public:
44 virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
45
Taylor Brandstetterba29c6a2016-06-27 16:30:35 -070046 // Audio or video receiver?
47 virtual cricket::MediaType media_type() const = 0;
48
deadbeef70ab1a12015-09-28 16:53:55 -070049 // Not to be confused with "mid", this is a field we can temporarily use
50 // to uniquely identify a receiver until we implement Unified Plan SDP.
51 virtual std::string id() const = 0;
52
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -070053 // The WebRTC specification only defines RTCRtpParameters in terms of senders,
54 // but this API also applies them to receivers, similar to ORTC:
55 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
56 virtual RtpParameters GetParameters() const = 0;
deadbeefb10f32f2017-02-08 01:38:21 -080057 // Currently, doesn't support changing any parameters, but may in the future.
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -070058 virtual bool SetParameters(const RtpParameters& parameters) = 0;
59
Taylor Brandstetterba29c6a2016-06-27 16:30:35 -070060 // Does not take ownership of observer.
61 // Must call SetObserver(nullptr) before the observer is destroyed.
zhihuang184a3fd2016-06-14 11:47:14 -070062 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
63
deadbeef70ab1a12015-09-28 16:53:55 -070064 protected:
65 virtual ~RtpReceiverInterface() {}
66};
67
68// Define proxy for RtpReceiverInterface.
deadbeefb10f32f2017-02-08 01:38:21 -080069// TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
70// are called on is an implementation detail.
nisse72c8d2b2016-04-15 03:49:07 -070071BEGIN_SIGNALING_PROXY_MAP(RtpReceiver)
deadbeefd99a2002017-01-18 08:55:23 -080072 PROXY_SIGNALING_THREAD_DESTRUCTOR()
73 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
74 PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
75 PROXY_CONSTMETHOD0(std::string, id)
76 PROXY_CONSTMETHOD0(RtpParameters, GetParameters);
77 PROXY_METHOD1(bool, SetParameters, const RtpParameters&)
78 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*);
olkafbcc5cb2017-04-10 04:38:13 -070079END_PROXY_MAP()
deadbeef70ab1a12015-09-28 16:53:55 -070080
81} // namespace webrtc
82
Henrik Kjellander15583c12016-02-10 10:53:12 +010083#endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_