Skip to content

Commit 98db8f1

Browse files
authored
starboard: Flatten various audio and decoder namespaces (#7156)
[go/cobalt-flatten-starboard-namespace](http://go/cobalt-flatten-starboard-namespace) #7132 uniquely named various audio and video decoders. Now we put those decoders in the flattened namespace and we don't need decoder-specific namespaces This PR also did some refactoring of replacing new with `make_unique`. #vibe-coded Bug: 441955897
1 parent 756ce18 commit 98db8f1

37 files changed

Lines changed: 94 additions & 131 deletions

starboard/android/shared/audio_decoder.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@
3636

3737
namespace starboard::android::shared {
3838

39-
class MediaCodecAudioDecoder
40-
: public ::starboard::shared::starboard::player::filter::AudioDecoder,
41-
public MediaCodecDecoder::Host,
42-
private JobQueue::JobOwner {
39+
class MediaCodecAudioDecoder : public AudioDecoder,
40+
public MediaCodecDecoder::Host,
41+
private JobQueue::JobOwner {
4342
public:
4443
typedef ::starboard::shared::starboard::media::AudioStreamInfo
4544
AudioStreamInfo;

starboard/android/shared/audio_decoder_passthrough.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ namespace starboard::android::shared {
3434
// in, without actually decoding the input audio. It can be used in situations
3535
// (like passthrough playbacks) where an AudioDecoder has to be used, but is
3636
// expected to not alter the input and pass it to the renderer as is.
37-
class AudioDecoderPassthrough
38-
: public ::starboard::shared::starboard::player::filter::AudioDecoder {
37+
class AudioDecoderPassthrough : public AudioDecoder {
3938
public:
4039
explicit AudioDecoderPassthrough(int samples_per_second)
4140
: samples_per_second_(samples_per_second) {}

starboard/android/shared/audio_renderer_passthrough.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ class AudioRendererPassthrough
102102
// TODO: Revisit to encapsulate the AudioDecoder as a SbDrmSystemPrivate
103103
// instead. This would need to turn SbDrmSystemPrivate::Decrypt() into
104104
// asynchronous, which comes with extra risks.
105-
std::unique_ptr<::starboard::shared::starboard::player::filter::AudioDecoder>
106-
decoder_;
105+
std::unique_ptr<AudioDecoder> decoder_;
107106

108107
// The following three variables are set in Initialize().
109108
ErrorCB error_cb_;

starboard/android/shared/player_components_factory.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,14 @@ class PlayerComponentsPassthrough
163163
class PlayerComponentsFactory : public starboard::shared::starboard::player::
164164
filter::PlayerComponents::Factory {
165165
typedef starboard::shared::starboard::media::MimeType MimeType;
166-
typedef starboard::shared::opus::OpusAudioDecoder OpusAudioDecoder;
167166
typedef starboard::shared::starboard::player::filter::AdaptiveAudioDecoder
168167
AdaptiveAudioDecoder;
169-
typedef starboard::shared::starboard::player::filter::AudioDecoder
170-
AudioDecoder;
171168
typedef starboard::shared::starboard::player::filter::AudioRendererSink
172169
AudioRendererSink;
173170
typedef starboard::shared::starboard::player::filter::AudioRendererSinkImpl
174171
AudioRendererSinkImpl;
175172
typedef starboard::shared::starboard::player::filter::PlayerComponents
176173
PlayerComponents;
177-
typedef starboard::shared::starboard::player::filter::VideoDecoder
178-
VideoDecoder;
179174
typedef starboard::shared::starboard::player::filter::VideoRenderAlgorithm
180175
VideoRenderAlgorithm;
181176
typedef starboard::shared::starboard::player::filter::VideoRendererSink

starboard/android/shared/video_decoder.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@
4444

4545
namespace starboard::android::shared {
4646

47-
class MediaCodecVideoDecoder
48-
: public ::starboard::shared::starboard::player::filter::VideoDecoder,
49-
public MediaCodecDecoder::Host,
50-
private JobQueue::JobOwner,
51-
private VideoSurfaceHolder {
47+
class MediaCodecVideoDecoder : public VideoDecoder,
48+
public MediaCodecDecoder::Host,
49+
private JobQueue::JobOwner,
50+
private VideoSurfaceHolder {
5251
public:
5352
typedef ::starboard::shared::starboard::media::VideoStreamInfo
5453
VideoStreamInfo;

starboard/linux/shared/media_is_video_supported.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace shared {
2828
namespace starboard {
2929
namespace media {
3030

31-
using ::starboard::shared::de265::is_de265_supported;
32-
3331
bool MediaIsVideoSupported(SbMediaVideoCodec video_codec,
3432
const MimeType* mime_type,
3533
int profile,

starboard/linux/shared/player_components_factory.cc

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ namespace filter {
5050

5151
namespace {
5252

53-
using ::starboard::shared::openh264::is_openh264_supported;
54-
5553
class PlayerComponentsFactory : public PlayerComponents::Factory {
5654
public:
5755
bool CreateSubComponents(
@@ -68,34 +66,30 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
6866
SB_DCHECK(audio_decoder);
6967
SB_DCHECK(audio_renderer_sink);
7068

71-
typedef ::starboard::shared::opus::OpusAudioDecoder OpusAudioDecoder;
72-
typedef ::starboard::shared::libfdkaac::FdkAacAudioDecoder
73-
FdkAacAudioDecoder;
74-
7569
auto decoder_creator =
7670
[](const media::AudioStreamInfo& audio_stream_info,
7771
SbDrmSystem drm_system) -> std::unique_ptr<AudioDecoder> {
7872
if (audio_stream_info.codec == kSbMediaAudioCodecOpus) {
79-
std::unique_ptr<OpusAudioDecoder> audio_decoder_impl(
80-
new OpusAudioDecoder(audio_stream_info));
81-
if (audio_decoder_impl->is_valid()) {
82-
return std::unique_ptr<AudioDecoder>(std::move(audio_decoder_impl));
73+
auto opus_audio_decoder =
74+
std::make_unique<OpusAudioDecoder>(audio_stream_info);
75+
if (opus_audio_decoder->is_valid()) {
76+
return opus_audio_decoder;
8377
} else {
8478
SB_LOG(ERROR) << "Failed to create audio decoder for codec "
8579
<< GetMediaAudioCodecName(audio_stream_info.codec);
8680
}
8781
} else if (audio_stream_info.codec == kSbMediaAudioCodecAac &&
8882
audio_stream_info.number_of_channels <=
8983
FdkAacAudioDecoder::kMaxChannels &&
90-
libfdkaac::LibfdkaacHandle::GetHandle()->IsLoaded()) {
84+
LibfdkaacHandle::GetHandle()->IsLoaded()) {
9185
SB_LOG(INFO) << "Playing audio using FdkAacAudioDecoder.";
92-
return std::unique_ptr<AudioDecoder>(new FdkAacAudioDecoder());
86+
return std::make_unique<FdkAacAudioDecoder>();
9387
} else {
94-
std::unique_ptr<FfmpegAudioDecoder> audio_decoder_impl(
88+
std::unique_ptr<FfmpegAudioDecoder> ffmpeg_audio_decoder(
9589
FfmpegAudioDecoder::Create(audio_stream_info));
96-
if (audio_decoder_impl && audio_decoder_impl->is_valid()) {
90+
if (ffmpeg_audio_decoder && ffmpeg_audio_decoder->is_valid()) {
9791
SB_LOG(INFO) << "Playing audio using FfmpegAudioDecoder";
98-
return std::unique_ptr<AudioDecoder>(std::move(audio_decoder_impl));
92+
return ffmpeg_audio_decoder;
9993
} else {
10094
SB_LOG(ERROR) << "Failed to create audio decoder for codec "
10195
<< GetMediaAudioCodecName(audio_stream_info.codec);
@@ -104,18 +98,13 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
10498
return nullptr;
10599
};
106100

107-
audio_decoder->reset(new AdaptiveAudioDecoder(
101+
*audio_decoder = std::make_unique<AdaptiveAudioDecoder>(
108102
creation_parameters.audio_stream_info(),
109-
creation_parameters.drm_system(), decoder_creator));
110-
audio_renderer_sink->reset(new AudioRendererSinkImpl);
103+
creation_parameters.drm_system(), decoder_creator);
104+
*audio_renderer_sink = std::make_unique<AudioRendererSinkImpl>();
111105
}
112106

113107
if (creation_parameters.video_codec() != kSbMediaVideoCodecNone) {
114-
using ::starboard::shared::de265::De265VideoDecoder;
115-
using ::starboard::shared::libdav1d::Dav1dVideoDecoder;
116-
using ::starboard::shared::openh264::OpenH264VideoDecoder;
117-
using ::starboard::shared::vpx::VpxVideoDecoder;
118-
119108
const int64_t kVideoSinkRenderIntervalUsec = 10'000;
120109

121110
SB_DCHECK(video_decoder);
@@ -190,8 +179,7 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
190179

191180
// static
192181
std::unique_ptr<PlayerComponents::Factory> PlayerComponents::Factory::Create() {
193-
return std::unique_ptr<PlayerComponents::Factory>(
194-
new PlayerComponentsFactory);
182+
return std::make_unique<PlayerComponentsFactory>();
195183
}
196184

197185
// static

starboard/raspi/shared/open_max/video_decoder.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636

3737
namespace starboard {
3838

39-
class OpenMaxVideoDecoder
40-
: public ::starboard::shared::starboard::player::filter::VideoDecoder,
41-
private JobQueue::JobOwner {
39+
class OpenMaxVideoDecoder : public VideoDecoder, private JobQueue::JobOwner {
4240
public:
4341
explicit OpenMaxVideoDecoder(SbMediaVideoCodec video_codec);
4442
~OpenMaxVideoDecoder() override;

starboard/raspi/shared/player_components_factory.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
5353
auto decoder_creator =
5454
[](const media::AudioStreamInfo& audio_stream_info,
5555
SbDrmSystem drm_system) -> std::unique_ptr<AudioDecoder> {
56-
using ::starboard::shared::opus::OpusAudioDecoder;
57-
5856
if (audio_stream_info.codec == kSbMediaAudioCodecOpus) {
5957
auto opus_audio_decoder =
6058
std::make_unique<OpusAudioDecoder>(audio_stream_info);
@@ -97,8 +95,7 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
9795

9896
// static
9997
std::unique_ptr<PlayerComponents::Factory> PlayerComponents::Factory::Create() {
100-
return std::unique_ptr<PlayerComponents::Factory>(
101-
new PlayerComponentsFactory);
98+
return std::make_unique<PlayerComponentsFactory>();
10299
}
103100

104101
// static

starboard/shared/ffmpeg/ffmpeg_audio_decoder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
namespace starboard {
2424

25-
class FfmpegAudioDecoder
26-
: public shared::starboard::player::filter::AudioDecoder {
25+
class FfmpegAudioDecoder : public AudioDecoder {
2726
public:
2827
typedef shared::starboard::media::AudioStreamInfo AudioStreamInfo;
2928

0 commit comments

Comments
 (0)