Commit a5151532 authored by Ken MacKay's avatar Ken MacKay Committed by Commit Bot

[Chromecast] Allow sounds to be played as other content types

Merge-With: eureka-internal/439192

Bug: internal b/162442148
Change-Id: I48246585ffde00158b1aa9ee7a6c403b6668259f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363447Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Kenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800598}
parent 5e6d2106
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromecast/public/volume_control.h"
namespace chromecast { namespace chromecast {
namespace media { namespace media {
...@@ -43,7 +44,7 @@ class CastSoundsManager { ...@@ -43,7 +44,7 @@ class CastSoundsManager {
bool repeat) = 0; bool repeat) = 0;
// Plays the sound added for |key|. // Plays the sound added for |key|.
virtual void Play(int key) = 0; virtual void Play(int key, AudioContentType content_type) = 0;
// Stops playing the sound added for |key| if it is currently playing. // Stops playing the sound added for |key| if it is currently playing.
virtual void Stop(int key) = 0; virtual void Stop(int key) = 0;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "chromecast/public/media/media_pipeline_device_params.h" #include "chromecast/public/media/media_pipeline_device_params.h"
#include "chromecast/public/volume_control.h"
namespace chromecast { namespace chromecast {
namespace media { namespace media {
...@@ -25,7 +26,10 @@ class SoundPlayer { ...@@ -25,7 +26,10 @@ class SoundPlayer {
// |sound_key| so the Stop() function can later identify which sound should be // |sound_key| so the Stop() function can later identify which sound should be
// stopped. If |repeat| is true, the sound is repeated until Stop() is called // stopped. If |repeat| is true, the sound is repeated until Stop() is called
// with the same |sound_key| or another sound is played. // with the same |sound_key| or another sound is played.
virtual void Play(int sound_key, int resource_id, bool repeat) = 0; virtual void Play(int sound_key,
int resource_id,
bool repeat,
AudioContentType content_type) = 0;
// Plays the sound using the provided |audio_data|. // Plays the sound using the provided |audio_data|.
// Once played, audio data is registered with a |sound_key| so the Stop() // Once played, audio data is registered with a |sound_key| so the Stop()
...@@ -34,14 +38,16 @@ class SoundPlayer { ...@@ -34,14 +38,16 @@ class SoundPlayer {
// |sound_key| or another sound is played. // |sound_key| or another sound is played.
virtual void PlayAudioData(int sound_key, virtual void PlayAudioData(int sound_key,
scoped_refptr<AudioData> audio_data, scoped_refptr<AudioData> audio_data,
bool repeat) = 0; bool repeat,
AudioContentType content_type) = 0;
// Plays the sound resource with |resource_id| starting at |timestamp|. // Plays the sound resource with |resource_id| starting at |timestamp|.
// Any sound that is currently playing is stopped immediately. // Any sound that is currently playing is stopped immediately.
// If |audio_channel| is kLeft or kRight, only that channel is played. // If |audio_channel| is kLeft or kRight, only that channel is played.
virtual void PlayAtTime(int resource_id, virtual void PlayAtTime(int resource_id,
int64_t timestamp, int64_t timestamp,
media::AudioChannel audio_channel) = 0; media::AudioChannel audio_channel,
AudioContentType content_type) = 0;
// Stops playing the sound resource with |resource_id| if it is currently // Stops playing the sound resource with |resource_id| if it is currently
// playing. // playing.
......
...@@ -21,7 +21,7 @@ class MockCastSoundsManager : public CastSoundsManager { ...@@ -21,7 +21,7 @@ class MockCastSoundsManager : public CastSoundsManager {
~MockCastSoundsManager() override; ~MockCastSoundsManager() override;
MOCK_METHOD4(AddSound, void(int, int, bool, bool)); MOCK_METHOD4(AddSound, void(int, int, bool, bool));
MOCK_METHOD4(AddSoundWithAudioData, void(int, const std::string, bool, bool)); MOCK_METHOD4(AddSoundWithAudioData, void(int, const std::string, bool, bool));
MOCK_METHOD1(Play, void(int)); MOCK_METHOD2(Play, void(int, AudioContentType));
MOCK_METHOD1(Stop, void(int)); MOCK_METHOD1(Stop, void(int));
void GetDuration(int key, DurationCallback callback) override { void GetDuration(int key, DurationCallback callback) override {
DoGetDuration(key, &callback); DoGetDuration(key, &callback);
......
...@@ -19,14 +19,14 @@ class MockSoundPlayer : public SoundPlayer { ...@@ -19,14 +19,14 @@ class MockSoundPlayer : public SoundPlayer {
MockSoundPlayer(); MockSoundPlayer();
~MockSoundPlayer() override; ~MockSoundPlayer() override;
MOCK_METHOD(void, Play, (int, int, bool), (override)); MOCK_METHOD(void, Play, (int, int, bool, AudioContentType), (override));
MOCK_METHOD(void, MOCK_METHOD(void,
PlayAudioData, PlayAudioData,
(int, scoped_refptr<AudioData>, bool), (int, scoped_refptr<AudioData>, bool, AudioContentType),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
PlayAtTime, PlayAtTime,
(int, int64_t, media::AudioChannel), (int, int64_t, media::AudioChannel, AudioContentType),
(override)); (override));
MOCK_METHOD(void, Stop, (int), (override)); MOCK_METHOD(void, Stop, (int), (override));
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment