diff --git a/shaka/include/shaka/media/frames.h b/shaka/include/shaka/media/frames.h index 2fd9bd9c..a1ae8fa0 100644 --- a/shaka/include/shaka/media/frames.h +++ b/shaka/include/shaka/media/frames.h @@ -16,6 +16,7 @@ #define SHAKA_EMBEDDED_MEDIA_FRAMES_H_ #include +#include #include #include "../eme/configuration.h" @@ -217,6 +218,10 @@ class SHAKA_EXPORT BaseFrame { * @return The estimated size of the frame, in bytes. */ virtual size_t EstimateSize() const; + + private: + class Impl; + std::unique_ptr impl_; }; /** @@ -264,6 +269,10 @@ class SHAKA_EXPORT EncodedFrame : public BaseFrame { size_t EstimateSize() const override; + + private: + class Impl; + std::unique_ptr impl_; }; /** @@ -317,6 +326,10 @@ class SHAKA_EXPORT DecodedFrame : public BaseFrame { size_t EstimateSize() const override; + + private: + class Impl; + std::unique_ptr impl_; }; } // namespace media diff --git a/shaka/include/shaka/media/media_track.h b/shaka/include/shaka/media/media_track.h index b735581d..edd8e280 100644 --- a/shaka/include/shaka/media/media_track.h +++ b/shaka/include/shaka/media/media_track.h @@ -104,6 +104,8 @@ class SHAKA_EXPORT MediaTrack { virtual void SetEnabled(bool enabled); private: + class Impl; + std::unique_ptr impl_; bool enabled_; }; diff --git a/shaka/src/media/frames.cc b/shaka/src/media/frames.cc index c1632c8e..4cbabaef 100644 --- a/shaka/src/media/frames.cc +++ b/shaka/src/media/frames.cc @@ -110,6 +110,8 @@ size_t GetPlaneCount(variant format, } +class BaseFrame::Impl {}; + BaseFrame::BaseFrame(std::shared_ptr stream_info, double pts, double dts, double duration, bool is_key_frame) : stream_info(stream_info), @@ -120,10 +122,12 @@ BaseFrame::BaseFrame(std::shared_ptr stream_info, double pts, BaseFrame::~BaseFrame() {} size_t BaseFrame::EstimateSize() const { - return sizeof(*this); + return sizeof(*this) + sizeof(Impl); } +class EncodedFrame::Impl {}; + EncodedFrame::EncodedFrame( std::shared_ptr stream, double pts, double dts, double duration, bool is_key_frame, const uint8_t* data, size_t data_size, @@ -156,10 +160,15 @@ MediaStatus EncodedFrame::Decrypt(const eme::Implementation* implementation, } size_t EncodedFrame::EstimateSize() const { - return sizeof(*this) + data_size; + // BaseFrame::EstimateSize includes sizeof(BaseFrame) and so does + // sizeof(this), so we need to remove the extra. + return BaseFrame::EstimateSize() + sizeof(*this) - sizeof(BaseFrame) + + data_size + sizeof(Impl); } +class DecodedFrame::Impl {}; + DecodedFrame::DecodedFrame(std::shared_ptr stream, double pts, double dts, double duration, variant format, @@ -174,7 +183,10 @@ DecodedFrame::DecodedFrame(std::shared_ptr stream, double pts, DecodedFrame::~DecodedFrame() {} size_t DecodedFrame::EstimateSize() const { - size_t ret = sizeof(*this); + // BaseFrame::EstimateSize includes sizeof(BaseFrame) and so does + // sizeof(this), so we need to remove the extra. + size_t ret = BaseFrame::EstimateSize() + sizeof(*this) - sizeof(BaseFrame) + + sizeof(Impl); for (size_t line : linesize) { if (holds_alternative(format)) ret += line * stream_info->height; diff --git a/shaka/src/media/media_track_public.cc b/shaka/src/media/media_track_public.cc index ee5874e8..7b3167b8 100644 --- a/shaka/src/media/media_track_public.cc +++ b/shaka/src/media/media_track_public.cc @@ -17,6 +17,8 @@ namespace shaka { namespace media { +class MediaTrack::Impl {}; + MediaTrack::MediaTrack(MediaTrackKind kind, const std::string& label, const std::string& language, const std::string& id) : label(label), language(language), id(id), kind(kind), enabled_(false) {}