Commit acbf9df3 authored by ziyangch's avatar ziyangch Committed by Commit Bot

[Chromecast] Fix the ac3 decoder error after enabling CMA on Android TV.

BUG=internal b/117626741

Test=Cast from Google Play Movie to nexus player.

Change-Id: Ibd4e50dd10f6abf538f2f5a76cb50b802aa47f62
Reviewed-on: https://chromium-review.googlesource.com/c/1297355
Commit-Queue: Ziyang Cheng <ziyangch@chromium.org>
Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603702}
parent 0530ec59
......@@ -168,8 +168,10 @@ CastContentBrowserClient::CastContentBrowserClient()
url_request_context_factory_(new URLRequestContextFactory()) {}
CastContentBrowserClient::~CastContentBrowserClient() {
#if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
DCHECK(!media_resource_tracker_)
<< "ResetMediaResourceTracker was not called";
#endif // BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
url_request_context_factory_.release());
}
......
......@@ -78,7 +78,10 @@ test("cast_media_unittests") {
if (is_cast_using_cma_backend) {
deps += [ "//chromecast/media/cma:unittests" ]
if (is_android) {
deps += [ "//chromecast/media/cma/backend/android:audio_track_java" ]
deps += [
"//chromecast/media/cma/backend/android:audio_track_java",
"//media/base/android:media_java",
]
shard_timeout = 300
}
}
......
......@@ -10,11 +10,16 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "chromecast/media/audio/cast_audio_mixer.h"
#include "chromecast/media/audio/cast_audio_output_stream.h"
#include "chromecast/media/cma/backend/cma_backend_factory.h"
#include "chromecast/public/cast_media_shlib.h"
#include "chromecast/public/media/media_pipeline_backend.h"
#if defined(OS_ANDROID)
#include "media/audio/android/audio_track_output_stream.h"
#endif // defined(OS_ANDROID)
namespace {
// TODO(alokp): Query the preferred value from media backend.
......@@ -160,6 +165,20 @@ CmaBackendFactory* CastAudioManager::cma_backend_factory() {
}
}
::media::AudioOutputStream* CastAudioManager::MakeBitstreamOutputStream(
const ::media::AudioParameters& params,
const std::string& device_id,
const ::media::AudioManager::LogCallback& log_callback) {
#if defined(OS_ANDROID)
DCHECK(params.IsBitstreamFormat());
return new ::media::AudioTrackOutputStream(this, params);
#else
NOTREACHED() << " Not implemented on non-android platform.";
return ::media::AudioManagerBase::MakeBitstreamOutputStream(params, device_id,
log_callback);
#endif // defined(OS_ANDROID)
}
::media::AudioInputStream* CastAudioManager::MakeLinearInputStream(
const ::media::AudioParameters& params,
const std::string& device_id,
......
......@@ -63,6 +63,10 @@ class CastAudioManager : public ::media::AudioManagerBase {
const ::media::AudioParameters& params,
const std::string& device_id,
const ::media::AudioManager::LogCallback& log_callback) override;
::media::AudioOutputStream* MakeBitstreamOutputStream(
const ::media::AudioParameters& params,
const std::string& device_id,
const ::media::AudioManager::LogCallback& log_callback) override;
::media::AudioInputStream* MakeLinearInputStream(
const ::media::AudioParameters& params,
const std::string& device_id,
......
......@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/test/scoped_task_environment.h"
#include "build/build_config.h"
#include "chromecast/common/mojom/constants.mojom.h"
#include "chromecast/common/mojom/multiroom.mojom.h"
#include "chromecast/media/cma/backend/cma_backend.h"
......@@ -23,6 +24,9 @@
#include "services/service_manager/public/cpp/connector.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "media/audio/android/audio_track_output_stream.h"
#endif // defined(OS_ANDROID)
using testing::_;
using testing::AnyNumber;
......@@ -189,6 +193,29 @@ TEST_F(CastAudioManagerTest, CanMakeStream) {
stream->Close();
}
#if defined(OS_ANDROID)
TEST_F(CastAudioManagerTest, CanMakeAC3Stream) {
const ::media::AudioParameters kAC3AudioParams(
::media::AudioParameters::AUDIO_BITSTREAM_AC3,
::media::CHANNEL_LAYOUT_5_1, ::media::AudioParameters::kAudioCDSampleRate,
256);
::media::AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream(
kAC3AudioParams, "", ::media::AudioManager::LogCallback());
EXPECT_TRUE(stream->Open());
EXPECT_CALL(mock_source_callback_, OnMoreData(_, _, _, _))
.WillRepeatedly(Invoke(OnMoreData));
EXPECT_CALL(mock_source_callback_, OnError()).Times(0);
stream->Start(&mock_source_callback_);
scoped_task_environment_.RunUntilIdle();
stream->Stop();
scoped_task_environment_.RunUntilIdle();
stream->Close();
}
#endif // defined(OS_ANDROID)
TEST_F(CastAudioManagerTest, CanMakeStreamProxy) {
SetUpBackendAndDecoder();
::media::AudioOutputStream* stream =
......
......@@ -112,7 +112,7 @@ class PlayReadyKeySystemProperties : public ::media::KeySystemProperties {
};
#endif // BUILDFLAG(ENABLE_PLAYREADY)
#if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
#if BUILDFLAG(USE_CHROMECAST_CDMS)
SupportedCodecs GetCastEmeSupportedCodecs() {
SupportedCodecs codecs = ::media::EME_CODEC_AAC | ::media::EME_CODEC_AVC1 |
::media::EME_CODEC_VP9_PROFILE0 |
......@@ -218,7 +218,7 @@ void AddChromecastKeySystems(
key_systems_properties,
bool enable_persistent_license_support,
bool force_software_crypto) {
#if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
#if BUILDFLAG(USE_CHROMECAST_CDMS)
AddCmaKeySystems(key_systems_properties, enable_persistent_license_support);
#elif defined(OS_ANDROID)
AddCastAndroidKeySystems(key_systems_properties);
......
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