Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: chromecast/media/base/cast_media_default.cc

Issue 1105803002: Exposes a shlib interface for media/audio path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment out streaming test until the default implementation is improved. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/public/cast_media_shlib.h" 5 #include "chromecast/public/cast_media_shlib.h"
6 #include "chromecast/public/graphics_types.h" 6 #include "chromecast/public/graphics_types.h"
7 #include "chromecast/public/media/cast_audio_output_device.h"
7 #include "chromecast/public/video_plane.h" 8 #include "chromecast/public/video_plane.h"
8 9
9 namespace chromecast { 10 namespace chromecast {
10 namespace media { 11 namespace media {
11 namespace { 12 namespace {
12 13
13 class DefaultVideoPlane : public VideoPlane { 14 class DefaultVideoPlane : public VideoPlane {
14 public: 15 public:
15 ~DefaultVideoPlane() override {} 16 ~DefaultVideoPlane() override {}
16 17
17 Size GetScreenResolution() override { 18 Size GetScreenResolution() override {
18 return Size(1920, 1080); 19 return Size(1920, 1080);
19 } 20 }
20 21
21 void SetGeometry(const RectF& display_rect, 22 void SetGeometry(const RectF& display_rect,
22 CoordinateType coordinate_type, 23 CoordinateType coordinate_type,
23 Transform transform) override {} 24 Transform transform) override {}
24 25
25 void OnScreenResolutionChanged(const Size& screen_res) override {} 26 void OnScreenResolutionChanged(const Size& screen_res) override {}
26 }; 27 };
27 28
29 class DefaultCastAudioOutputDevice : public CastAudioOutputDevice {
30 public:
31 DefaultCastAudioOutputDevice() {}
32 ~DefaultCastAudioOutputDevice() override {}
33
34 int GetMaximumOutputStreamsAllowed() override { return 0; }
35
36 AudioParameters GetPreferredOutputStreamParameters(
37 const AudioParameters& suggested) override {
38 return AudioParameters();
39 }
40
41 CastAudioOutputStream* MakeOutputStream(const AudioParameters& params,
42 TaskRunner* task_runner) override {
43 return nullptr; // No streams allowed, always return nullptr
44 }
45 };
46
47 class DefaultCastAudioOutputStream : public CastAudioOutputStream {
48 public:
49 explicit DefaultCastAudioOutputStream(const AudioParameters& params)
50 : params_(params) {}
51 ~DefaultCastAudioOutputStream() override {}
52
53 // CastAudioOutputStream implementation:
54 AudioParameters GetParameters() override { return params_; }
55 bool Open() override { return false; }
56 void Start(AudioSourceCallback* callback) override {}
57 void Stop() override {}
58 void SetVolume(double volume) override {}
59 double GetVolume() override { return 0.0; }
60 void Close() override {}
61
62 private:
63 AudioParameters params_;
64 };
65
28 DefaultVideoPlane* g_video_plane = nullptr; 66 DefaultVideoPlane* g_video_plane = nullptr;
67 DefaultCastAudioOutputDevice* g_audio_output_device = nullptr;
29 68
30 } // namespace 69 } // namespace
31 70
32 void CastMediaShlib::Initialize(const std::vector<std::string>& argv) { 71 void CastMediaShlib::Initialize(const std::vector<std::string>& argv) {
33 g_video_plane = new DefaultVideoPlane(); 72 g_video_plane = new DefaultVideoPlane();
34 } 73 }
35 74
36 void CastMediaShlib::Finalize() { 75 void CastMediaShlib::Finalize() {
37 delete g_video_plane; 76 delete g_video_plane;
38 g_video_plane = nullptr; 77 g_video_plane = nullptr;
78
79 if (g_audio_output_device) {
80 delete g_audio_output_device;
81 g_audio_output_device = nullptr;
82 }
39 } 83 }
40 84
41 VideoPlane* CastMediaShlib::GetVideoPlane() { 85 VideoPlane* CastMediaShlib::GetVideoPlane() {
42 return g_video_plane; 86 return g_video_plane;
43 } 87 }
44 88
89 CastAudioOutputDevice* CastMediaShlib::GetAudioOutputDevice() {
90 if (!g_audio_output_device)
91 g_audio_output_device = new DefaultCastAudioOutputDevice();
92 return g_audio_output_device;
93 }
94
45 } // namespace media 95 } // namespace media
46 } // namespace chromecast 96 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698