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

Side by Side Diff: chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.cc

Issue 1786733004: Revert of media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 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 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/media/cma/ipc_streamer/audio_decoder_config_marshaller.h" 5 #include "chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chromecast/media/cma/ipc/media_message.h" 13 #include "chromecast/media/cma/ipc/media_message.h"
14 #include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h"
15 #include "media/base/audio_decoder_config.h" 14 #include "media/base/audio_decoder_config.h"
16 15
17 namespace chromecast { 16 namespace chromecast {
18 namespace media { 17 namespace media {
19 18
20 namespace { 19 namespace {
21 const size_t kMaxExtraDataSize = 16 * 1024; 20 const size_t kMaxExtraDataSize = 16 * 1024;
22 } 21 }
23 22
24 // static 23 // static
25 void AudioDecoderConfigMarshaller::Write( 24 void AudioDecoderConfigMarshaller::Write(
26 const ::media::AudioDecoderConfig& config, MediaMessage* msg) { 25 const ::media::AudioDecoderConfig& config, MediaMessage* msg) {
27 CHECK(msg->WritePod(config.codec())); 26 CHECK(msg->WritePod(config.codec()));
28 CHECK(msg->WritePod(config.channel_layout())); 27 CHECK(msg->WritePod(config.channel_layout()));
29 CHECK(msg->WritePod(config.samples_per_second())); 28 CHECK(msg->WritePod(config.samples_per_second()));
30 CHECK(msg->WritePod(config.sample_format())); 29 CHECK(msg->WritePod(config.sample_format()));
31 EncryptionSchemeMarshaller::Write(config.encryption_scheme(), msg); 30 CHECK(msg->WritePod(config.is_encrypted()));
32 CHECK(msg->WritePod(config.extra_data().size())); 31 CHECK(msg->WritePod(config.extra_data().size()));
33 if (!config.extra_data().empty()) 32 if (!config.extra_data().empty())
34 CHECK(msg->WriteBuffer(&config.extra_data()[0], 33 CHECK(msg->WriteBuffer(&config.extra_data()[0],
35 config.extra_data().size())); 34 config.extra_data().size()));
36 } 35 }
37 36
38 // static 37 // static
39 ::media::AudioDecoderConfig AudioDecoderConfigMarshaller::Read( 38 ::media::AudioDecoderConfig AudioDecoderConfigMarshaller::Read(
40 MediaMessage* msg) { 39 MediaMessage* msg) {
41 ::media::AudioCodec codec; 40 ::media::AudioCodec codec;
42 ::media::SampleFormat sample_format; 41 ::media::SampleFormat sample_format;
43 ::media::ChannelLayout channel_layout; 42 ::media::ChannelLayout channel_layout;
44 int samples_per_second; 43 int samples_per_second;
44 bool is_encrypted;
45 size_t extra_data_size; 45 size_t extra_data_size;
46 std::vector<uint8_t> extra_data; 46 std::vector<uint8_t> extra_data;
47 ::media::EncryptionScheme encryption_scheme;
48 47
49 CHECK(msg->ReadPod(&codec)); 48 CHECK(msg->ReadPod(&codec));
50 CHECK(msg->ReadPod(&channel_layout)); 49 CHECK(msg->ReadPod(&channel_layout));
51 CHECK(msg->ReadPod(&samples_per_second)); 50 CHECK(msg->ReadPod(&samples_per_second));
52 CHECK(msg->ReadPod(&sample_format)); 51 CHECK(msg->ReadPod(&sample_format));
53 encryption_scheme = EncryptionSchemeMarshaller::Read(msg); 52 CHECK(msg->ReadPod(&is_encrypted));
54 CHECK(msg->ReadPod(&extra_data_size)); 53 CHECK(msg->ReadPod(&extra_data_size));
55 54
56 CHECK_GE(codec, ::media::kUnknownAudioCodec); 55 CHECK_GE(codec, ::media::kUnknownAudioCodec);
57 CHECK_LE(codec, ::media::kAudioCodecMax); 56 CHECK_LE(codec, ::media::kAudioCodecMax);
58 CHECK_GE(channel_layout, ::media::CHANNEL_LAYOUT_NONE); 57 CHECK_GE(channel_layout, ::media::CHANNEL_LAYOUT_NONE);
59 CHECK_LE(channel_layout, ::media::CHANNEL_LAYOUT_MAX); 58 CHECK_LE(channel_layout, ::media::CHANNEL_LAYOUT_MAX);
60 CHECK_GE(sample_format, ::media::kUnknownSampleFormat); 59 CHECK_GE(sample_format, ::media::kUnknownSampleFormat);
61 CHECK_LE(sample_format, ::media::kSampleFormatMax); 60 CHECK_LE(sample_format, ::media::kSampleFormatMax);
62 CHECK_LT(extra_data_size, kMaxExtraDataSize); 61 CHECK_LT(extra_data_size, kMaxExtraDataSize);
63 if (extra_data_size > 0) { 62 if (extra_data_size > 0) {
64 extra_data.resize(extra_data_size); 63 extra_data.resize(extra_data_size);
65 CHECK(msg->ReadBuffer(&extra_data[0], extra_data.size())); 64 CHECK(msg->ReadBuffer(&extra_data[0], extra_data.size()));
66 } 65 }
67 66
68 return ::media::AudioDecoderConfig( 67 return ::media::AudioDecoderConfig(
69 codec, sample_format, 68 codec, sample_format,
70 channel_layout, samples_per_second, 69 channel_layout, samples_per_second,
71 extra_data, encryption_scheme); 70 extra_data, is_encrypted);
72 } 71 }
73 72
74 } // namespace media 73 } // namespace media
75 } // namespace chromecast 74 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cma/ipc_streamer/BUILD.gn ('k') | chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698