Move pc/media_stream_track.h to the api/ directory
This file is being accessed from Chrome. Moving it lessens the dependency of Chrome on files in the pc/ directory, and allows easier refactoring of pc/. Bug: webrtc:11967 Change-Id: Iccd568f84e9cf4086e37c58db1b4cba6c376f413 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/187489 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32378}
This commit is contained in:

committed by
Commit Bot

parent
72cc54c5b8
commit
9cb42c8690
@ -98,6 +98,7 @@ rtc_library("media_stream_interface") {
|
||||
sources = [
|
||||
"media_stream_interface.cc",
|
||||
"media_stream_interface.h",
|
||||
"media_stream_track.h",
|
||||
"notifier.h",
|
||||
]
|
||||
deps = [
|
||||
|
63
api/media_stream_track.h
Normal file
63
api/media_stream_track.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_MEDIA_STREAM_TRACK_H_
|
||||
#define API_MEDIA_STREAM_TRACK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/notifier.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// MediaTrack implements the interface common to AudioTrackInterface and
|
||||
// VideoTrackInterface.
|
||||
template <typename T>
|
||||
class MediaStreamTrack : public Notifier<T> {
|
||||
public:
|
||||
typedef typename T::TrackState TypedTrackState;
|
||||
|
||||
std::string id() const override { return id_; }
|
||||
MediaStreamTrackInterface::TrackState state() const override {
|
||||
return state_;
|
||||
}
|
||||
bool enabled() const override { return enabled_; }
|
||||
bool set_enabled(bool enable) override {
|
||||
bool fire_on_change = (enable != enabled_);
|
||||
enabled_ = enable;
|
||||
if (fire_on_change) {
|
||||
Notifier<T>::FireOnChanged();
|
||||
}
|
||||
return fire_on_change;
|
||||
}
|
||||
void set_ended() { set_state(MediaStreamTrackInterface::TrackState::kEnded); }
|
||||
|
||||
protected:
|
||||
explicit MediaStreamTrack(const std::string& id)
|
||||
: enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {}
|
||||
|
||||
bool set_state(MediaStreamTrackInterface::TrackState new_state) {
|
||||
bool fire_on_change = (state_ != new_state);
|
||||
state_ = new_state;
|
||||
if (fire_on_change)
|
||||
Notifier<T>::FireOnChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
const std::string id_;
|
||||
MediaStreamTrackInterface::TrackState state_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_MEDIA_STREAM_TRACK_H_
|
@ -14,8 +14,8 @@
|
||||
#include <string>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/media_stream_track.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "pc/media_stream_track.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright 2020 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -7,58 +7,9 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef PC_MEDIA_STREAM_TRACK_H_
|
||||
#define PC_MEDIA_STREAM_TRACK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/notifier.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// MediaTrack implements the interface common to AudioTrackInterface and
|
||||
// VideoTrackInterface.
|
||||
template <typename T>
|
||||
class MediaStreamTrack : public Notifier<T> {
|
||||
public:
|
||||
typedef typename T::TrackState TypedTrackState;
|
||||
|
||||
std::string id() const override { return id_; }
|
||||
MediaStreamTrackInterface::TrackState state() const override {
|
||||
return state_;
|
||||
}
|
||||
bool enabled() const override { return enabled_; }
|
||||
bool set_enabled(bool enable) override {
|
||||
bool fire_on_change = (enable != enabled_);
|
||||
enabled_ = enable;
|
||||
if (fire_on_change) {
|
||||
Notifier<T>::FireOnChanged();
|
||||
}
|
||||
return fire_on_change;
|
||||
}
|
||||
void set_ended() { set_state(MediaStreamTrackInterface::TrackState::kEnded); }
|
||||
|
||||
protected:
|
||||
explicit MediaStreamTrack(const std::string& id)
|
||||
: enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {}
|
||||
|
||||
bool set_state(MediaStreamTrackInterface::TrackState new_state) {
|
||||
bool fire_on_change = (state_ != new_state);
|
||||
state_ = new_state;
|
||||
if (fire_on_change)
|
||||
Notifier<T>::FireOnChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
const std::string id_;
|
||||
MediaStreamTrackInterface::TrackState state_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
// Temporary header forwarding
|
||||
#include "api/media_stream_track.h"
|
||||
|
||||
#endif // PC_MEDIA_STREAM_TRACK_H_
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/str_replace.h"
|
||||
#include "api/media_stream_track.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/stats/rtc_stats_report.h"
|
||||
#include "api/stats/rtcstats_objects.h"
|
||||
@ -31,7 +32,6 @@
|
||||
#include "p2p/base/p2p_constants.h"
|
||||
#include "p2p/base/port.h"
|
||||
#include "pc/media_stream.h"
|
||||
#include "pc/media_stream_track.h"
|
||||
#include "pc/test/fake_data_channel_provider.h"
|
||||
#include "pc/test/fake_peer_connection_for_stats.h"
|
||||
#include "pc/test/mock_data_channel.h"
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/candidate.h"
|
||||
#include "api/data_channel_interface.h"
|
||||
#include "api/media_stream_track.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "call/call.h"
|
||||
#include "media/base/media_channel.h"
|
||||
#include "modules/audio_processing/include/audio_processing_statistics.h"
|
||||
#include "pc/media_stream.h"
|
||||
#include "pc/media_stream_track.h"
|
||||
#include "pc/sctp_data_channel.h"
|
||||
#include "pc/test/fake_peer_connection_for_stats.h"
|
||||
#include "pc/test/fake_video_track_source.h"
|
||||
|
@ -14,12 +14,12 @@
|
||||
#include <string>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/media_stream_track.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_sink_interface.h"
|
||||
#include "api/video/video_source_interface.h"
|
||||
#include "media/base/video_source_base.h"
|
||||
#include "pc/media_stream_track.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
|
Reference in New Issue
Block a user