OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gpu/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 incoming_bundle_ = nullptr; | 479 incoming_bundle_ = nullptr; |
480 return; | 480 return; |
481 } | 481 } |
482 | 482 |
483 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an | 483 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an |
484 // incoming bundle properly, since we don't want to accidentally overwrite | 484 // incoming bundle properly, since we don't want to accidentally overwrite |
485 // |surface_bundle| for a codec that's being released elsewhere. | 485 // |surface_bundle| for a codec that's being released elsewhere. |
486 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager | 486 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager |
487 // to create the surface texture. We can probably make an overlay impl out | 487 // to create the surface texture. We can probably make an overlay impl out |
488 // of it, and provide the surface texture to |picture_buffer_manager_|. | 488 // of it, and provide the surface texture to |picture_buffer_manager_|. |
489 if (incoming_bundle_->overlay) { | 489 if (!picture_buffer_manager_.Initialize(incoming_bundle_)) { |
490 picture_buffer_manager_.InitializeForOverlay(); | 490 NOTIFY_ERROR(PLATFORM_FAILURE, "Could not allocate surface texture"); |
491 } else { | 491 incoming_bundle_ = nullptr; |
492 incoming_bundle_->surface_texture_surface = | 492 return; |
493 picture_buffer_manager_.InitializeForSurfaceTexture(); | |
494 incoming_bundle_->surface_texture = | |
495 picture_buffer_manager_.surface_texture(); | |
496 | |
497 if (!incoming_bundle_->surface_texture) { | |
498 NOTIFY_ERROR(PLATFORM_FAILURE, "Could not allocate surface texture"); | |
499 incoming_bundle_ = nullptr; | |
500 return; | |
501 } | |
502 } | 493 } |
503 | 494 |
504 // If we have a media codec, then SetSurface. If that doesn't work, then we | 495 // If we have a media codec, then SetSurface. If that doesn't work, then we |
505 // do not try to allocate a new codec; we might not be at a keyframe, etc. | 496 // do not try to allocate a new codec; we might not be at a keyframe, etc. |
506 // If we get here with a codec, then we must setSurface. | 497 // If we get here with a codec, then we must setSurface. |
507 if (media_codec_) { | 498 if (media_codec_) { |
508 // TODO(liberato): fail on api check? | 499 // TODO(liberato): fail on api check? |
509 if (!media_codec_->SetSurface(incoming_bundle_->j_surface().obj())) { | 500 if (!media_codec_->SetSurface(incoming_bundle_->j_surface().obj())) { |
510 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces."); | 501 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces."); |
511 // We're not going to use |incoming_bundle_|. | 502 // We're not going to use |incoming_bundle_|. |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), | 1675 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), |
1685 codec_config_->surface_bundle); | 1676 codec_config_->surface_bundle); |
1686 } | 1677 } |
1687 | 1678 |
1688 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { | 1679 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { |
1689 ReleaseCodec(); | 1680 ReleaseCodec(); |
1690 codec_config_->surface_bundle = nullptr; | 1681 codec_config_->surface_bundle = nullptr; |
1691 } | 1682 } |
1692 | 1683 |
1693 } // namespace media | 1684 } // namespace media |
OLD | NEW |