aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_flv/ifc_flvaudiodecoder.h
blob: 66ae264b2bca65e43b5e641adf795c4dd5e89860 (plain) (blame)
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
#pragma once

enum
{
	FLV_AUDIO_SUCCESS = 0,
	FLV_AUDIO_FAILURE = 1,
	FLV_AUDIO_NEEDS_MORE_INPUT = 2,
};

class ifc_flvaudiodecoder : public Dispatchable
{
protected:
	ifc_flvaudiodecoder() {}
	~ifc_flvaudiodecoder() {}
public:
	int GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits);
	int DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate);
	void Flush();
	void Close();
	int Ready(); // returns 1 for ready [default], 0 for not ready.  Some codecs in FLV use the first packet for decoder config data.  return 1 from this once you've gotten it
	void SetPreferences(unsigned int max_channels, unsigned int preferred_bits);
	DISPATCH_CODES
	{
		FLV_AUDIO_GETOUTPUTFORMAT = 0,
			FLV_AUDIO_DECODE = 1,
			FLV_AUDIO_FLUSH = 2,
			FLV_AUDIO_CLOSE = 3,
			FLV_AUDIO_READY = 4,
			FLV_AUDIO_SETPREFERENCES=5,
	};
};

inline int ifc_flvaudiodecoder::GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits)
{
	return _call(FLV_AUDIO_GETOUTPUTFORMAT, (int)FLV_AUDIO_FAILURE, sample_rate, channels, bits);
}

inline int ifc_flvaudiodecoder::DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate)
{
	return _call(FLV_AUDIO_DECODE, (int)FLV_AUDIO_FAILURE, input_buffer, input_buffer_bytes, samples, samples_size_bytes, bitrate);
}

inline void ifc_flvaudiodecoder::Flush()
{
	_voidcall(FLV_AUDIO_FLUSH);
}

inline void ifc_flvaudiodecoder::Close()
{
	_voidcall(FLV_AUDIO_CLOSE);
}

inline int ifc_flvaudiodecoder::Ready()
{
	return _call(FLV_AUDIO_READY, (int)1); // default to true so that decoders that don't implement won't block in_flv from seeking
}

inline void ifc_flvaudiodecoder::SetPreferences(unsigned int max_channels, unsigned int preferred_bits)
{
	_voidcall(FLV_AUDIO_SETPREFERENCES, max_channels, preferred_bits);
}