dom/media/platforms/apple/AppleVTDecoder.h
author JW Wang <jwwang@mozilla.com>
Mon, 06 Jun 2016 16:17:15 +0800
branch1274214_remove_WMFMediaDataDecoder_TaskQueue
changeset 375982 c305c4627f13211a1c718fa1f4f2ed69773fb14e
parent 367765 5bb3981b0c70d1fb3ec763f25654e3cc38f9ee2f
child 388886 8a5852b04fe6250d711178cefa63c9223c5066da
permissions -rw-r--r--
Bug 1274466 - per discussion move some functions back to public. r?jya. MozReview-Commit-ID: BoTB5IKjuDD

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_AppleVTDecoder_h
#define mozilla_AppleVTDecoder_h

#include "AppleVDADecoder.h"

#include "VideoToolbox/VideoToolbox.h"

namespace mozilla {

class AppleVTDecoder : public AppleVDADecoder {
public:
  AppleVTDecoder(const VideoInfo& aConfig,
                 TaskQueue* aTaskQueue,
                 MediaDataDecoderCallback* aCallback,
                 layers::ImageContainer* aImageContainer);

  RefPtr<InitPromise> Init() override;
  bool IsHardwareAccelerated(nsACString& aFailureReason) const override
  {
    return mIsHardwareAccelerated;
  }

  const char* GetDescriptionName() const override
  {
    return mIsHardwareAccelerated
      ? "apple hardware VT decoder"
      : "apple software VT decoder";
  }

private:
  virtual ~AppleVTDecoder();
  void ProcessFlush() override;
  void ProcessDrain() override;
  void ProcessShutdown() override;

  CMVideoFormatDescriptionRef mFormat;
  VTDecompressionSessionRef mSession;

  // Method to pass a frame to VideoToolbox for decoding.
  nsresult DoDecode(MediaRawData* aSample) override;
  // Method to set up the decompression session.
  nsresult InitializeSession();
  nsresult WaitForAsynchronousFrames();
  CFDictionaryRef CreateDecoderSpecification();
  CFDictionaryRef CreateDecoderExtensions();
  Atomic<bool> mIsHardwareAccelerated;
};

} // namespace mozilla

#endif // mozilla_AppleVTDecoder_h