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

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 11414138: Encrypted Media: No NeedKey if --enable-encrypted-media is not set. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: resolve comments Created 8 years 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 (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/filters/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 if (!stream) { 150 if (!stream) {
151 status_cb.Run(PIPELINE_ERROR_DECODE); 151 status_cb.Run(PIPELINE_ERROR_DECODE);
152 return; 152 return;
153 } 153 }
154 154
155 demuxer_stream_ = stream; 155 demuxer_stream_ = stream;
156 statistics_cb_ = statistics_cb; 156 statistics_cb_ = statistics_cb;
157 157
158 if (!ConfigureDecoder()) { 158 if (!ConfigureDecoder()) {
159 status_cb.Run(PIPELINE_ERROR_DECODE); 159 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED);
160 return; 160 return;
161 } 161 }
162 162
163 // Success! 163 // Success!
164 state_ = kNormal; 164 state_ = kNormal;
165 status_cb.Run(PIPELINE_OK); 165 status_cb.Run(PIPELINE_OK);
166 } 166 }
167 167
168 void FFmpegVideoDecoder::Read(const ReadCB& read_cb) { 168 void FFmpegVideoDecoder::Read(const ReadCB& read_cb) {
169 // Complete operation asynchronously on different stack of execution as per 169 // Complete operation asynchronously on different stack of execution as per
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 496
497 bool FFmpegVideoDecoder::ConfigureDecoder() { 497 bool FFmpegVideoDecoder::ConfigureDecoder() {
498 const VideoDecoderConfig& config = demuxer_stream_->video_decoder_config(); 498 const VideoDecoderConfig& config = demuxer_stream_->video_decoder_config();
499 499
500 if (!config.IsValidConfig()) { 500 if (!config.IsValidConfig()) {
501 DLOG(ERROR) << "Invalid video stream - " << config.AsHumanReadableString(); 501 DLOG(ERROR) << "Invalid video stream - " << config.AsHumanReadableString();
502 return false; 502 return false;
503 } 503 }
504 504
505 if (config.is_encrypted() && !decryptor_) {
506 DLOG(ERROR) << "Encrypted video stream not supported.";
507 return false;
508 }
509
505 // Release existing decoder resources if necessary. 510 // Release existing decoder resources if necessary.
506 ReleaseFFmpegResources(); 511 ReleaseFFmpegResources();
507 512
508 // Initialize AVCodecContext structure. 513 // Initialize AVCodecContext structure.
509 codec_context_ = avcodec_alloc_context3(NULL); 514 codec_context_ = avcodec_alloc_context3(NULL);
510 VideoDecoderConfigToAVCodecContext(config, codec_context_); 515 VideoDecoderConfigToAVCodecContext(config, codec_context_);
511 516
512 // Enable motion vector search (potentially slow), strong deblocking filter 517 // Enable motion vector search (potentially slow), strong deblocking filter
513 // for damaged macroblocks, and set our error detection sensitivity. 518 // for damaged macroblocks, and set our error detection sensitivity.
514 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; 519 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
515 codec_context_->err_recognition = AV_EF_CAREFUL; 520 codec_context_->err_recognition = AV_EF_CAREFUL;
516 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id); 521 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id);
517 codec_context_->opaque = this; 522 codec_context_->opaque = this;
518 codec_context_->flags |= CODEC_FLAG_EMU_EDGE; 523 codec_context_->flags |= CODEC_FLAG_EMU_EDGE;
519 codec_context_->get_buffer = GetVideoBufferImpl; 524 codec_context_->get_buffer = GetVideoBufferImpl;
520 codec_context_->release_buffer = ReleaseVideoBufferImpl; 525 codec_context_->release_buffer = ReleaseVideoBufferImpl;
521 526
522 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); 527 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
523 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { 528 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) {
524 ReleaseFFmpegResources(); 529 ReleaseFFmpegResources();
525 return false; 530 return false;
526 } 531 }
527 532
528 av_frame_ = avcodec_alloc_frame(); 533 av_frame_ = avcodec_alloc_frame();
529 return true; 534 return true;
530 } 535 }
531 536
532 } // namespace media 537 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698