codec_picture.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_GPU_CODEC_PICTURE_H_
  5. #define MEDIA_GPU_CODEC_PICTURE_H_
  6. #include <vector>
  7. #include "base/memory/ref_counted.h"
  8. #include "media/base/decrypt_config.h"
  9. #include "media/base/video_color_space.h"
  10. #include "media/gpu/media_gpu_export.h"
  11. #include "ui/gfx/geometry/rect.h"
  12. namespace media {
  13. // Represents a picture encoded (or to be encoded) with a video codec, such as
  14. // VP8. Users of this class do not require knowledge of the codec format, or any
  15. // codec-specific details related to the picture, but may otherwise need to pass
  16. // or keep references to the picture, e.g. to keep a list of reference pictures
  17. // required for a codec task valid until it is finished. Also used for storing
  18. // non-codec-specific metadata.
  19. class MEDIA_GPU_EXPORT CodecPicture
  20. : public base::RefCountedThreadSafe<CodecPicture> {
  21. public:
  22. CodecPicture();
  23. CodecPicture(const CodecPicture&) = delete;
  24. CodecPicture& operator=(const CodecPicture&) = delete;
  25. int32_t bitstream_id() const { return bitstream_id_; }
  26. void set_bitstream_id(int32_t bitstream_id) { bitstream_id_ = bitstream_id; }
  27. const gfx::Rect visible_rect() const { return visible_rect_; }
  28. void set_visible_rect(const gfx::Rect& rect) { visible_rect_ = rect; }
  29. // DecryptConfig returned by this method describes the decryption
  30. // configuration of the input stream for this picture. Returns null if it is
  31. // not encrypted.
  32. const DecryptConfig* decrypt_config() const { return decrypt_config_.get(); }
  33. void set_decrypt_config(std::unique_ptr<DecryptConfig> config) {
  34. decrypt_config_ = std::move(config);
  35. }
  36. // Populate with an unspecified colorspace by default.
  37. const VideoColorSpace& get_colorspace() const { return colorspace_; }
  38. void set_colorspace(const VideoColorSpace& colorspace) {
  39. colorspace_ = colorspace;
  40. }
  41. protected:
  42. friend class base::RefCountedThreadSafe<CodecPicture>;
  43. virtual ~CodecPicture();
  44. private:
  45. int32_t bitstream_id_ = -1;
  46. gfx::Rect visible_rect_;
  47. std::unique_ptr<DecryptConfig> decrypt_config_;
  48. VideoColorSpace colorspace_;
  49. };
  50. } // namespace media
  51. #endif // MEDIA_GPU_CODEC_PICTURE_H_