aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_flv/FLVReader.h
blob: 27e6818363ca258643e7dcd27ad9d70427bfb651 (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
#ifndef NULLSOFT_IN_FLV_FLVREADER_H
#define NULLSOFT_IN_FLV_FLVREADER_H

#include <windows.h>
#include <bfc/platform/types.h>
#include "FLVStreamheader.h"
#include "../nu/AutoLock.h"
#include "BackgroundDownloader.h"
#include "FLVProcessor.h"

class FLVReader : private Downloader::DownloadCallback
{
public:
	FLVReader(const wchar_t *_url);
	~FLVReader();

	bool GetFrame(size_t frameIndex, FrameData &frameData);
	bool GetPosition(int time_in_ms, size_t *frameIndex, bool needVideoKeyFrame);
	uint64_t Seek(uint64_t position);
	size_t Read(void *data, size_t bytes);
	void Kill();
	void SignalKill();
	bool IsEOF();
	uint32_t GetMaxTimestamp();
	uint64_t GetProcessedPosition();
	bool IsStreaming();
	FLVHeader *GetHeader();
private:
	void ProcessFile();
	int OnConnect(api_httpreceiver *http);
	int OnData(void *data, size_t datalen);
	int Process();
	DWORD CALLBACK ParserThread();
	static DWORD CALLBACK ParserThreadStub(LPVOID param) { return ((FLVReader *)param)->ParserThread(); }

private:
	bool killswitch;

	HANDLE flvThread;
	bool end_of_stream;
	wchar_t *url;

	/* because we won't know until after opening the stream whether it's progressive download
	or a real-time stream, we need have a pointer to a virtual base class to do the processing
	we'll create a different one depending on what kind of stream */
	FLVProcessor *processor;
};

#endif