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

Side by Side Diff: webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.h

Issue 11260007: Add FFmpeg audio decoder for the clear key CDM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on master and 11242005. Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_AUDIO_DECODER_H_
6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_AUDIO_DECODER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/time.h"
12 #include "base/compiler_specific.h"
13 #include "webkit/media/crypto/ppapi/content_decryption_module.h"
14
15 struct AVCodecContext;
16 struct AVFrame;
17
18 namespace webkit_media {
19
20 class FFmpegCdmAudioDecoder {
21 public:
22 explicit FFmpegCdmAudioDecoder(cdm::Allocator* allocator);
23 ~FFmpegCdmAudioDecoder();
24 bool Initialize(const cdm::AudioDecoderConfig& config);
25 void Deinitialize();
26 void Reset();
27
28 // Returns true when |config| is a valid audio decoder configuration.
29 static bool IsValidConfig(const cdm::AudioDecoderConfig& config);
30
31 // Decodes |compressed_buffer|. Returns |cdm::kSuccess| after storing
32 // output in |decoded_frames| when output is available. Returns
33 // |cdm::kNeedMoreData| when |compressed_frame| does not produce output.
34 // Returns |cdm::kDecodeError| when decoding fails.
35 cdm::Status DecodeBuffer(const uint8_t* compressed_buffer,
36 int32_t compressed_buffer_size,
37 int64_t timestamp,
38 cdm::AudioFrames* decoded_frames);
39
40 private:
41 void ResetAudioTimingData();
42 void ReleaseFFmpegResources();
43
44 base::TimeDelta GetNextOutputTimestamp() const;
45
46 void SerializeInt64(int64_t value);
47
48 bool is_initialized_;
49
50 cdm::Allocator* const allocator_;
51
52 // FFmpeg structures owned by this object.
53 AVCodecContext* codec_context_;
54 AVFrame* av_frame_;
55
56 // Decoded audio format.
ddorwin 2012/10/25 01:27:18 Just "Audio format"? Decoded makes it sound like a
Tom Finegan 2012/10/25 01:42:19 Done.
57 int bits_per_channel_;
58 int samples_per_second_;
59
60 // Used for computing output timestamps.
61 int bytes_per_frame_;
62 base::TimeDelta output_timestamp_base_;
63 int64_t total_frames_decoded_;
64 base::TimeDelta last_input_timestamp_;
65
66 // Number of output sample bytes to drop before generating
ddorwin 2012/10/25 01:27:18 Why would one want to do that?
Tom Finegan 2012/10/25 01:42:19 Because Vorbis and negative timestamps. Comment in
67 // output buffers.
68 int output_bytes_to_drop_;
69
70 typedef std::vector<uint8_t> SerializedAudioFrames;
71 SerializedAudioFrames serialized_audio_frames_;
72
73 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmAudioDecoder);
74 };
75
76 } // namespace webkit_media
77
78 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698