1 // Copyright 2014 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 MEDIA_FORMATS_WEBM_WEBM_AUDIO_CLIENT_H_ 6 #define MEDIA_FORMATS_WEBM_WEBM_AUDIO_CLIENT_H_ 7 8 #include <stdint.h> 9 10 #include <string> 11 #include <vector> 12 13 #include "base/macros.h" 14 #include "media/base/encryption_scheme.h" 15 #include "media/base/media_log.h" 16 #include "media/formats/webm/webm_parser.h" 17 18 namespace media { 19 class AudioDecoderConfig; 20 21 // Helper class used to parse an Audio element inside a TrackEntry element. 22 class WebMAudioClient : public WebMParserClient { 23 public: 24 explicit WebMAudioClient(MediaLog* media_log); 25 ~WebMAudioClient() override; 26 27 // Reset this object's state so it can process a new audio track element. 28 void Reset(); 29 30 // Initialize |config| with the data in |codec_id|, |codec_private|, 31 // |encryption_scheme| and the fields parsed from the last audio track element 32 // this object was used to parse. 33 // Returns true if |config| was successfully initialized. 34 // Returns false if there was unexpected values in the provided parameters or 35 // audio track element fields. 36 bool InitializeConfig(const std::string& codec_id, 37 const std::vector<uint8_t>& codec_private, 38 const int64_t seek_preroll, 39 const int64_t codec_delay, 40 EncryptionScheme encryption_scheme, 41 AudioDecoderConfig* config); 42 43 private: 44 // WebMParserClient implementation. 45 bool OnUInt(int id, int64_t val) override; 46 bool OnFloat(int id, double val) override; 47 48 MediaLog* media_log_; 49 int channels_; 50 double samples_per_second_; 51 double output_samples_per_second_; 52 53 DISALLOW_COPY_AND_ASSIGN(WebMAudioClient); 54 }; 55 56 } // namespace media 57 58 #endif // MEDIA_FORMATS_WEBM_WEBM_AUDIO_CLIENT_H_ 59