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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 incoming_bundle_ = nullptr; | 490 incoming_bundle_ = nullptr; |
491 return; | 491 return; |
492 } | 492 } |
493 | 493 |
494 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an | 494 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an |
495 // incoming bundle properly, since we don't want to accidentally overwrite | 495 // incoming bundle properly, since we don't want to accidentally overwrite |
496 // |surface_bundle| for a codec that's being released elsewhere. | 496 // |surface_bundle| for a codec that's being released elsewhere. |
497 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager | 497 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager |
498 // to create the surface texture. We can probably make an overlay impl out | 498 // to create the surface texture. We can probably make an overlay impl out |
499 // of it, and provide the surface texture to |picture_buffer_manager_|. | 499 // of it, and provide the surface texture to |picture_buffer_manager_|. |
500 if (incoming_bundle_->overlay) { | 500 if (!picture_buffer_manager_.Initialize(incoming_bundle_)) { |
501 picture_buffer_manager_.InitializeForOverlay(); | 501 NOTIFY_ERROR(PLATFORM_FAILURE, "Could not allocate surface texture"); |
502 } else { | 502 incoming_bundle_ = nullptr; |
503 incoming_bundle_->surface_texture_surface = | 503 return; |
504 picture_buffer_manager_.InitializeForSurfaceTexture(); | |
505 incoming_bundle_->surface_texture = | |
506 picture_buffer_manager_.surface_texture(); | |
507 | |
508 if (!incoming_bundle_->surface_texture) { | |
509 NOTIFY_ERROR(PLATFORM_FAILURE, "Could not allocate surface texture"); | |
510 incoming_bundle_ = nullptr; | |
511 return; | |
512 } | |
513 } | 504 } |
514 | 505 |
515 // If we have a media codec, then SetSurface. If that doesn't work, then we | 506 // If we have a media codec, then SetSurface. If that doesn't work, then we |
516 // do not try to allocate a new codec; we might not be at a keyframe, etc. | 507 // do not try to allocate a new codec; we might not be at a keyframe, etc. |
517 // If we get here with a codec, then we must setSurface. | 508 // If we get here with a codec, then we must setSurface. |
518 if (media_codec_) { | 509 if (media_codec_) { |
519 // TODO(liberato): fail on api check? | 510 // TODO(liberato): fail on api check? |
520 if (!media_codec_->SetSurface(incoming_bundle_->j_surface().obj())) { | 511 if (!media_codec_->SetSurface(incoming_bundle_->j_surface().obj())) { |
521 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces."); | 512 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces."); |
522 // We're not going to use |incoming_bundle_|. | 513 // We're not going to use |incoming_bundle_|. |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), | 1692 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), |
1702 codec_config_->surface_bundle); | 1693 codec_config_->surface_bundle); |
1703 } | 1694 } |
1704 | 1695 |
1705 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { | 1696 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { |
1706 ReleaseCodec(); | 1697 ReleaseCodec(); |
1707 codec_config_->surface_bundle = nullptr; | 1698 codec_config_->surface_bundle = nullptr; |
1708 } | 1699 } |
1709 | 1700 |
1710 } // namespace media | 1701 } // namespace media |
OLD | NEW |