-
Notifications
You must be signed in to change notification settings - Fork 4
/
sample_source.h
71 lines (60 loc) · 1.63 KB
/
sample_source.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// Created by wlanjie on 2018/3/31.
//
#ifndef MP4_SAMPLE_SOURCE_H
#define MP4_SAMPLE_SOURCE_H
#include "types.h"
#include "sample.h"
#include "sampledescription.h"
#include "track.h"
namespace mp4 {
class SampleSource {
public:
SampleSource(){}
virtual ~SampleSource() {}
/**
* return the timescale of the sample's media
* @return
*/
virtual UI32 getTimeScale() = 0;
/**
* return the duration in milliseconds
* @return
*/
virtual UI32 getDurationMs() = 0;
/**
* read the next sample form the source
* @param sample
* @param buffer
* @param trackId
* @return
*/
virtual Result readNextSample(Sample& sample, DataBuffer& buffer, UI32& trackId) = 0;
/**
* seek to the sample closest to a specific timestamp in milliseconds
* @param timeMs
* @param before
* @return
*/
virtual Result seekToTime(UI32 timeMs, bool before = true) = 0;
/**
* return a sample description by index
* @param index
* @return NULL if there is no sample description with the requested index.
*/
virtual SampleDescription* getSampleDescription(Ordinal index) = 0;
};
class TrackSampleSource : public SampleSource {
public:
TrackSampleSource(Track* track);
UI32 getTimeScale() override ;
UI32 getDurationMs() override ;
Result readNextSample(Sample& sample, DataBuffer& buffer, UI32& trackId) override ;
Result seekToTime(UI32 timeMs, bool before = true);
SampleDescription* getSampleDescription(Ordinal index) override ;
private:
Track* track;
Ordinal sampleIndex;
};
}
#endif //MP4_SAMPLE_SOURCE_H