Create a MediaTransportState enum and add a state callback to MediaTransport.

Bug: webrtc:9719
Change-Id: Icf7004be5e3a2784fccc1d910c8b77ea3b3d5156
Reviewed-on: https://webrtc-review.googlesource.com/c/108501
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Peter Slatala <psla@webrtc.org>
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25438}
This commit is contained in:
Bjorn Mellem 2018-10-29 15:21:31 -07:00 committed by Commit Bot
parent eaf337a141
commit c78b0ea615

View File

@ -209,6 +209,25 @@ class MediaTransportVideoSinkInterface {
virtual void OnKeyFrameRequested(uint64_t channel_id) = 0;
};
// State of the media transport. Media transport begins in the pending state.
// It transitions to writable when it is ready to send media. It may transition
// back to pending if the connection is blocked. It may transition to closed at
// any time. Closed is terminal: a transport will never re-open once closed.
enum class MediaTransportState {
kPending,
kWritable,
kClosed,
};
// Callback invoked whenever the state of the media transport changes.
class MediaTransportStateCallback {
public:
virtual ~MediaTransportStateCallback() = default;
// Invoked whenever the state of the media transport changes.
virtual void OnStateChanged(MediaTransportState state) = 0;
};
// Media transport interface for sending / receiving encoded audio/video frames
// and receiving bandwidth estimate update from congestion control.
class MediaTransportInterface {
@ -250,6 +269,14 @@ class MediaTransportInterface {
virtual void SetTargetTransferRateObserver(
webrtc::TargetTransferRateObserver* observer) = 0;
// Sets a state observer callback. Before media transport is destroyed, the
// callback must be unregistered by setting it to nullptr.
// A newly registered callback will be called with the current state.
// Media transport does not invoke this callback concurrently.
// TODO(mellem): Make this pure virtual once all implementations support it.
virtual void SetMediaTransportStateCallback(
MediaTransportStateCallback* callback) {}
// TODO(sukhanov): RtcEventLogs.
};