file_stream.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This file is part of the FreeStreamer project,
  3. * (C)Copyright 2011-2018 Matias Muhonen <mmu@iki.fi> 穆马帝
  4. * See the file ''LICENSE'' for using the code.
  5. *
  6. * https://github.com/muhku/FreeStreamer
  7. */
  8. #ifndef ASTREAMER_FILE_STREAM_H
  9. #define ASTREAMER_FILE_STREAM_H
  10. #import "input_stream.h"
  11. #import "id3_parser.h"
  12. namespace astreamer {
  13. class File_Stream : public Input_Stream {
  14. private:
  15. File_Stream(const File_Stream&);
  16. File_Stream& operator=(const File_Stream&);
  17. CFURLRef m_url;
  18. CFReadStreamRef m_readStream;
  19. bool m_scheduledInRunLoop;
  20. bool m_readPending;
  21. Input_Stream_Position m_position;
  22. UInt8 *m_fileReadBuffer;
  23. ID3_Parser *m_id3Parser;
  24. CFStringRef m_contentType;
  25. static void readCallBack(CFReadStreamRef stream, CFStreamEventType eventType, void *clientCallBackInfo);
  26. public:
  27. File_Stream();
  28. virtual ~File_Stream();
  29. Input_Stream_Position position();
  30. CFStringRef contentType();
  31. void setContentType(CFStringRef contentType);
  32. size_t contentLength();
  33. bool open();
  34. bool open(const Input_Stream_Position& position);
  35. void close();
  36. void setScheduledInRunLoop(bool scheduledInRunLoop);
  37. void setUrl(CFURLRef url);
  38. static bool canHandleUrl(CFURLRef url);
  39. /* ID3_Parser_Delegate */
  40. void id3metaDataAvailable(std::map<CFStringRef,CFStringRef> metaData);
  41. void id3tagSizeAvailable(UInt32 tagSize);
  42. };
  43. } // namespace astreamer
  44. #endif // ASTREAMER_FILE_STREAM_H