MCPcopy Create free account
hub / github.com/FFMS/ffms2 / FFMS_AudioSource

Method FFMS_AudioSource

src/core/audiosource.cpp:56–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56FFMS_AudioSource::FFMS_AudioSource(const char *SourceFile, FFMS_Index &Index, int Track, int DelayMode, int FillGaps, double DrcScale)
57 : DrcScale(DrcScale), LastValidTS(AV_NOPTS_VALUE), SourceFile(SourceFile), ResampleContext{ swr_alloc() }, TrackNumber(Track) {
58 try {
59 if (FillGaps < -1 || FillGaps > 1)
60 throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_INVALID_ARGUMENT,
61 "Invalid gap fill mode");
62
63 if (Track < 0 || Track >= static_cast<int>(Index.size()))
64 throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_INVALID_ARGUMENT,
65 "Out of bounds track index selected");
66
67 if (Index[Track].TT != FFMS_TYPE_AUDIO)
68 throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_INVALID_ARGUMENT,
69 "Not an audio track");
70
71 if (Index[Track].empty())
72 throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_INVALID_ARGUMENT,
73 "Audio track contains no audio frames");
74
75 if (!Index.CompareFileSignature(SourceFile))
76 throw FFMS_Exception(FFMS_ERROR_INDEX, FFMS_ERROR_FILE_MISMATCH,
77 "The index does not match the source file");
78
79 Frames = Index[Track];
80 LAVFOpts = Index.LAVFOpts;
81
82 DecodeFrame = av_frame_alloc();
83 if (!DecodeFrame)
84 throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
85 "Couldn't allocate frame");
86 OpenFile();
87
88 if (FillGaps == 1 || (FillGaps == -1 && (!strcmp(FormatContext->iformat->name, "flv"))))
89 Frames.FillAudioGaps();
90
91 if (Frames.back().PTS == Frames.front().PTS)
92 SeekOffset = -1;
93 else
94 SeekOffset = 10;
95
96 Init(Index, DelayMode);
97 } catch (...) {
98 Free();
99 throw;
100 }
101}
102
103
104#define EXCESSIVE_CACHE_SIZE 400

Callers

nothing calls this directly

Calls 8

FFMS_ExceptionClass · 0.85
FreeClass · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
CompareFileSignatureMethod · 0.80
FillAudioGapsMethod · 0.80
backMethod · 0.80
frontMethod · 0.80

Tested by

no test coverage detected