1
0

Header.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "Header.h"
  2. #include <windows.h>
  3. #include "header_avi.h"
  4. #include "header_mpg.h"
  5. #include "header_asf.h"
  6. #include "header_wav.h"
  7. extern const wchar_t *extension(const wchar_t *fn);
  8. Header *MakeHeader(const wchar_t *filename, bool metadata)
  9. {
  10. const wchar_t *ext=extension(filename);
  11. Header *header=0;
  12. if(!_wcsicmp(ext, L"asf") || !_wcsicmp(ext, L"wmv") || !_wcsicmp(ext, L"wma"))
  13. header = new HeaderAsf();
  14. else if(!_wcsicmp(ext, L"avi") || !_wcsicmp(ext, L"divx"))
  15. header = new HeaderAvi();
  16. else if(!_wcsicmp(ext, L"mpg") || !_wcsicmp(ext, L"mpeg"))
  17. header = new HeaderMpg();
  18. else if (!_wcsicmp(ext, L"wav"))
  19. header = new HeaderWav();
  20. if (header && !header->getInfos(filename, metadata))
  21. {
  22. delete header;
  23. return 0;
  24. }
  25. return header;
  26. }
  27. Header::Header()
  28. {
  29. length = -1;
  30. has_audio = has_video = false;
  31. title = artist = comment = genre = album = composer = publisher = 0;
  32. audio_nch = audio_bps = audio_srate = video_w = video_h = 0;
  33. }
  34. Header::~Header()
  35. {
  36. free(title);
  37. free(artist);
  38. free(comment);
  39. free(genre);
  40. free(album);
  41. free(composer);
  42. free(publisher);
  43. }