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: media/webm/webm_stream_parser.cc

Issue 10829470: Support for parsing encrypted WebM streams by src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase code. Add support for audio. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "media/webm/webm_stream_parser.h" 5 #include "media/webm/webm_stream_parser.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "media/ffmpeg/ffmpeg_common.h" 11 #include "media/ffmpeg/ffmpeg_common.h"
12 #include "media/filters/ffmpeg_glue.h" 12 #include "media/filters/ffmpeg_glue.h"
13 #include "media/filters/in_memory_url_protocol.h" 13 #include "media/filters/in_memory_url_protocol.h"
14 #include "media/webm/webm_cluster_parser.h" 14 #include "media/webm/webm_cluster_parser.h"
15 #include "media/webm/webm_constants.h" 15 #include "media/webm/webm_constants.h"
16 #include "media/webm/webm_content_encodings.h" 16 #include "media/webm/webm_content_encodings.h"
17 #include "media/webm/webm_crypto_helpers.h"
17 #include "media/webm/webm_info_parser.h" 18 #include "media/webm/webm_info_parser.h"
18 #include "media/webm/webm_tracks_parser.h" 19 #include "media/webm/webm_tracks_parser.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
23 static const char kWebMInitDataType[] = "video/webm";
24
25 // Helper class that uses FFmpeg to create AudioDecoderConfig & 23 // Helper class that uses FFmpeg to create AudioDecoderConfig &
26 // VideoDecoderConfig objects. 24 // VideoDecoderConfig objects.
27 // 25 //
28 // This dependency on FFmpeg can be removed once we update WebMTracksParser 26 // This dependency on FFmpeg can be removed once we update WebMTracksParser
29 // to parse the necessary data to construct AudioDecoderConfig & 27 // to parse the necessary data to construct AudioDecoderConfig &
30 // VideoDecoderConfig objects. http://crbug.com/108756 28 // VideoDecoderConfig objects. http://crbug.com/108756
31 class FFmpegConfigHelper { 29 class FFmpegConfigHelper {
32 public: 30 public:
33 FFmpegConfigHelper(); 31 FFmpegConfigHelper();
34 ~FFmpegConfigHelper(); 32 ~FFmpegConfigHelper();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 147
150 bool no_supported_streams = true; 148 bool no_supported_streams = true;
151 for (size_t i = 0; i < format_context->nb_streams; ++i) { 149 for (size_t i = 0; i < format_context->nb_streams; ++i) {
152 AVStream* stream = format_context->streams[i]; 150 AVStream* stream = format_context->streams[i];
153 AVCodecContext* codec_context = stream->codec; 151 AVCodecContext* codec_context = stream->codec;
154 AVMediaType codec_type = codec_context->codec_type; 152 AVMediaType codec_type = codec_context->codec_type;
155 153
156 if (codec_type == AVMEDIA_TYPE_AUDIO && 154 if (codec_type == AVMEDIA_TYPE_AUDIO &&
157 stream->codec->codec_id == CODEC_ID_VORBIS && 155 stream->codec->codec_id == CODEC_ID_VORBIS &&
158 !audio_config_.IsValidConfig()) { 156 !audio_config_.IsValidConfig()) {
159 AVCodecContextToAudioDecoderConfig(stream->codec, &audio_config_); 157 AVCodecContextToAudioDecoderConfig(stream->codec, false, &audio_config_);
ddorwin 2013/03/10 21:29:39 Just call AVStreamToAudioDecoderConfig like the vi
fgalligan1 2013/03/12 00:42:42 Done.
160 no_supported_streams = false; 158 no_supported_streams = false;
161 continue; 159 continue;
162 } 160 }
163 161
164 if (codec_type == AVMEDIA_TYPE_VIDEO && 162 if (codec_type == AVMEDIA_TYPE_VIDEO &&
165 stream->codec->codec_id == CODEC_ID_VP8 && 163 stream->codec->codec_id == CODEC_ID_VP8 &&
166 !video_config_.IsValidConfig()) { 164 !video_config_.IsValidConfig()) {
167 AVStreamToVideoDecoderConfig(stream, &video_config_); 165 AVStreamToVideoDecoderConfig(stream, &video_config_);
168 no_supported_streams = false; 166 no_supported_streams = false;
169 continue; 167 continue;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 end_of_segment_cb_.Run(); 464 end_of_segment_cb_.Run();
467 465
468 return bytes_parsed; 466 return bytes_parsed;
469 } 467 }
470 468
471 void WebMStreamParser::FireNeedKey(const std::string& key_id) { 469 void WebMStreamParser::FireNeedKey(const std::string& key_id) {
472 int key_id_size = key_id.size(); 470 int key_id_size = key_id.size();
473 DCHECK_GT(key_id_size, 0); 471 DCHECK_GT(key_id_size, 0);
474 scoped_array<uint8> key_id_array(new uint8[key_id_size]); 472 scoped_array<uint8> key_id_array(new uint8[key_id_size]);
475 memcpy(key_id_array.get(), key_id.data(), key_id_size); 473 memcpy(key_id_array.get(), key_id.data(), key_id_size);
476 need_key_cb_.Run(kWebMInitDataType, key_id_array.Pass(), key_id_size); 474 need_key_cb_.Run(kWebMEncryptInitDataType, key_id_array.Pass(), key_id_size);
477 } 475 }
478 476
479 } // namespace media 477 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698