123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #ifndef OGG_PACKET_SEQUENCE_H
- #define OGG_PACKET_SEQUENCE_H
- #include "core/io/resource.h"
- #include "core/variant/typed_array.h"
- #include "core/variant/variant.h"
- #include <ogg/ogg.h>
- class OggPacketSequencePlayback;
- class OggPacketSequence : public Resource {
- GDCLASS(OggPacketSequence, Resource);
- friend class OggPacketSequencePlayback;
-
- Vector<Vector<PackedByteArray>> page_data;
-
- Vector<uint64_t> page_granule_positions;
-
- int64_t end_page = 0;
- uint64_t data_version = 0;
- float sampling_rate = 0;
- float length = 0;
- protected:
- static void _bind_methods();
- public:
-
-
- void push_page(int64_t p_granule_pos, const Vector<PackedByteArray> &p_data);
- void set_packet_data(const TypedArray<Array> &p_data);
- TypedArray<Array> get_packet_data() const;
- void set_packet_granule_positions(const PackedInt64Array &p_granule_positions);
- PackedInt64Array get_packet_granule_positions() const;
-
-
- void set_sampling_rate(float p_sampling_rate);
-
- float get_sampling_rate() const;
-
- float get_length() const;
-
- int64_t get_final_granule_pos() const;
- Ref<OggPacketSequencePlayback> instantiate_playback();
- OggPacketSequence() {}
- virtual ~OggPacketSequence() {}
- };
- class OggPacketSequencePlayback : public RefCounted {
- GDCLASS(OggPacketSequencePlayback, RefCounted);
- friend class OggPacketSequence;
- Ref<OggPacketSequence> ogg_packet_sequence;
- mutable int64_t page_cursor = 0;
- mutable int32_t packet_cursor = 0;
- mutable ogg_packet *packet;
- uint64_t data_version = 0;
- mutable int64_t packetno = 0;
-
- uint32_t seek_page_internal(int64_t granule, uint32_t after_page_inclusive, uint32_t before_page_inclusive);
- public:
-
-
- bool next_ogg_packet(ogg_packet **p_packet) const;
-
-
-
- bool seek_page(int64_t p_granule_pos);
-
- int64_t get_page_number() const;
-
-
- bool set_page_number(int64_t p_page_number);
- OggPacketSequencePlayback();
- virtual ~OggPacketSequencePlayback();
- };
- #endif
|