FLVReader.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef NULLSOFT_IN_FLV_FLVREADER_H
  2. #define NULLSOFT_IN_FLV_FLVREADER_H
  3. #include <windows.h>
  4. #include <bfc/platform/types.h>
  5. #include "FLVStreamheader.h"
  6. #include "../nu/AutoLock.h"
  7. #include "BackgroundDownloader.h"
  8. #include "FLVProcessor.h"
  9. class FLVReader : private Downloader::DownloadCallback
  10. {
  11. public:
  12. FLVReader(const wchar_t *_url);
  13. ~FLVReader();
  14. bool GetFrame(size_t frameIndex, FrameData &frameData);
  15. bool GetPosition(int time_in_ms, size_t *frameIndex, bool needVideoKeyFrame);
  16. uint64_t Seek(uint64_t position);
  17. size_t Read(void *data, size_t bytes);
  18. void Kill();
  19. void SignalKill();
  20. bool IsEOF();
  21. uint32_t GetMaxTimestamp();
  22. uint64_t GetProcessedPosition();
  23. bool IsStreaming();
  24. FLVHeader *GetHeader();
  25. private:
  26. void ProcessFile();
  27. int OnConnect(api_httpreceiver *http);
  28. int OnData(void *data, size_t datalen);
  29. int Process();
  30. DWORD CALLBACK ParserThread();
  31. static DWORD CALLBACK ParserThreadStub(LPVOID param) { return ((FLVReader *)param)->ParserThread(); }
  32. private:
  33. bool killswitch;
  34. HANDLE flvThread;
  35. bool end_of_stream;
  36. wchar_t *url;
  37. /* because we won't know until after opening the stream whether it's progressive download
  38. or a real-time stream, we need have a pointer to a virtual base class to do the processing
  39. we'll create a different one depending on what kind of stream */
  40. FLVProcessor *processor;
  41. };
  42. #endif