NuPlayer2DecoderPassThrough.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2017 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef NUPLAYER2_DECODER_PASS_THROUGH_H_
  17. #define NUPLAYER2_DECODER_PASS_THROUGH_H_
  18. #include "NuPlayer2.h"
  19. #include "NuPlayer2DecoderBase.h"
  20. namespace android {
  21. struct NuPlayer2::DecoderPassThrough : public DecoderBase {
  22. DecoderPassThrough(const sp<AMessage> &notify,
  23. const sp<Source> &source,
  24. const sp<Renderer> &renderer);
  25. protected:
  26. virtual ~DecoderPassThrough();
  27. virtual void onMessageReceived(const sp<AMessage> &msg);
  28. virtual void onConfigure(const sp<AMessage> &format);
  29. virtual void onSetParameters(const sp<AMessage> &params);
  30. virtual void onSetRenderer(const sp<Renderer> &renderer);
  31. virtual void onResume(bool notifyComplete);
  32. virtual void onFlush();
  33. virtual void onShutdown(bool notifyComplete);
  34. virtual bool doRequestBuffers();
  35. private:
  36. enum {
  37. kWhatBufferConsumed = 'bufC',
  38. };
  39. sp<Source> mSource;
  40. sp<Renderer> mRenderer;
  41. int64_t mSkipRenderingUntilMediaTimeUs;
  42. bool mReachedEOS;
  43. // Used by feedDecoderInputData to aggregate small buffers into
  44. // one large buffer.
  45. sp<ABuffer> mPendingAudioAccessUnit;
  46. status_t mPendingAudioErr;
  47. sp<ABuffer> mAggregateBuffer;
  48. // mPendingBuffersToDrain are only for debugging. It can be removed
  49. // when the power investigation is done.
  50. size_t mPendingBuffersToDrain;
  51. size_t mCachedBytes;
  52. AString mComponentName;
  53. bool isStaleReply(const sp<AMessage> &msg);
  54. bool isDoneFetching() const;
  55. status_t dequeueAccessUnit(sp<ABuffer> *accessUnit);
  56. sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
  57. status_t fetchInputData(sp<AMessage> &reply);
  58. void doFlush(bool notifyComplete);
  59. void onInputBufferFetched(const sp<AMessage> &msg);
  60. void onBufferConsumed(int32_t size);
  61. DISALLOW_EVIL_CONSTRUCTORS(DecoderPassThrough);
  62. };
  63. } // namespace android
  64. #endif // NUPLAYER2_DECODER_PASS_THROUGH_H_