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

Side by Side Diff: chromecast/public/media/cast_audio_output_stream.h

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
« no previous file with comments | « chromecast/public/media/cast_audio_output_device.h ('k') | chromecast/public/task_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMECAST_PUBLIC_CAST_AUDIO_OUTPUT_STREAM_H_
6 #define CHROMECAST_PUBLIC_CAST_AUDIO_OUTPUT_STREAM_H_
7
8 #include <stdint.h>
9
10 namespace chromecast {
11 namespace media {
12
13 // A simple struct describing an audio stream.
14 struct AudioParameters {
15 int sample_rate; // Sampling frequency/rate.
16 int bits_per_sample; // Number of bits per sample.
17 int frames_per_buffer; // Number of frames in a buffer.
18 int channels; // Number of channels.
19
20 static const int kMaxSampleRate = 192000;
21 static const int kMaxBitsPerSample = 32;
22 static const int kMaxFramesPerBuffer = kMaxSampleRate;
23 static const int kMaxChannels = 32; // The maximum number of channels.
24 };
25
26 // This is an interface for a Cast audio output stream. Implementations of this
27 // interface are responsible for making calls to an AudioSourceCallback.
28 class CastAudioOutputStream {
29 public:
30 // Audio sources must implement AudioSourceCallback. Calls to this interface
31 // must be made on the same thread on which the stream object is created.
32 class AudioSourceCallback {
33 protected:
34 virtual ~AudioSourceCallback() {}
byungchul 2015/07/30 22:12:16 protected should go after public ones.
35
36 public:
37 // The CastAudioOutputStream calls this to request more data from the
38 // source. This method fills |dest| with |frames| frames of interleaved
39 // data, which takes the following struture for N channels:
40 //
41 // [ch0, ch1, ..., chN, ch0, ch1, ..., chN, ...]
42 // |<---- Frame 0 ---->|<---- Frame 1 ---->|...|
43 //
44 // |len| is the size of |dest| in bytes, and must satisfy the following:
45 //
46 // |len| >= |frames| * (num channels) * (bytes per sample)
47 //
48 // where bytes per sample and channels are properties of the stream. These
49 // can be detemined through GetParameters(). |total_bytes_delay| contains
50 // the current number of bytes of delay buffered by the
51 // CastAudioOutputStream. Returns the number of frames successfully filled.
52 virtual int GetMoreData(void* dest,
53 uint32_t len,
54 int32_t frames,
55 uint32_t total_bytes_delay) = 0;
56
57 // There was an error while playing a buffer. Audio source cannot be
58 // destroyed yet. No direct action needed by the AudioStream, but it is
59 // a good place to stop accumulating sound data since is is likely that
60 // playback will not continue.
61 virtual void OnError(CastAudioOutputStream* stream) = 0;
62 };
63
64 virtual ~CastAudioOutputStream() {}
65
66 // Returns the parameters describing the stream.
67 virtual AudioParameters GetParameters() = 0;
68
69 // Open the stream. A call to this method will always be followed by a call to
70 // Close() even if Open() fails. This method may block the caller's thread.
71 virtual bool Open() = 0;
72
73 // Starts playing audio and generating AudioSourceCallback::GetMoreData().
74 // Since implementor of CastAudioOutputStream may have internal buffers, right
75 // after calling this method initial buffers are fetched.
76 //
77 // The output stream does not take ownership of this callback.
78 virtual void Start(AudioSourceCallback* callback) = 0;
79
80 // Stops playing audio. Effect might not be instantaneous as the hardware
81 // might have locked audio data that is processing.
82 virtual void Stop() = 0;
83
84 // Sets the relative volume, with range [0.0, 1.0] inclusive.
85 virtual void SetVolume(double volume) = 0;
86
87 // Gets the relative volume, with range [0.0, 1.0] inclusive. This method may
88 // be .
89 virtual double GetVolume() = 0;
90
91 // Close the stream. This also generates AudioSourceCallback::OnClose().
92 // After calling this method, the object should not be used anymore. Like all
93 // other methods, this must be made on the same thread on which the stream was
94 // created.
95 virtual void Close() = 0;
96 };
97
98 } // namespace media
99 } // namespace chromecast
100
101 #endif // CHROMECAST_PUBLIC_CAST_AUDIO_OUTPUT_STREAM_H_
OLDNEW
« no previous file with comments | « chromecast/public/media/cast_audio_output_device.h ('k') | chromecast/public/task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698