1
0

ExtendedFileInfo.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include <bfc/platform/types.h>
  2. #include <windows.h>
  3. #include "api__in_mkv.h"
  4. #include "MKVInfo.h"
  5. #include <strsafe.h>
  6. #include "resource.h"
  7. extern "C" __declspec(dllexport)
  8. int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, size_t destlen)
  9. {
  10. if (!_stricmp(data, "type"))
  11. {
  12. dest[0]='1';
  13. dest[1]=0;
  14. return 1;
  15. }
  16. else if (!_stricmp(data, "family"))
  17. {
  18. int len;
  19. const wchar_t *p;
  20. if (!fn || !fn[0]) return 0;
  21. len = lstrlenW(fn);
  22. if ((len>3 && L'.' == fn[len-4]))
  23. {
  24. p = &fn[len - 3];
  25. if (!_wcsicmp(p, L"MKV") && S_OK == StringCchCopyW(dest, destlen, WASABI_API_LNGSTRINGW(IDS_FAMILY_STRING))) return 1;
  26. }
  27. else if (len>4 && L'.' == fn[len-5])
  28. {
  29. p = &fn[len - 4];
  30. if (!_wcsicmp(p, L"webm") && S_OK == StringCchCopyW(dest, destlen, WASABI_API_LNGSTRINGW(IDS_FAMILY_STRING_WEBM))) return 1;
  31. }
  32. return 0;
  33. }
  34. else
  35. {
  36. MKVInfo info;
  37. dest[0]=0;
  38. if (!_stricmp(data, "length"))
  39. {
  40. if (info.Open(fn))
  41. StringCchPrintf(dest, destlen, L"%d", info.GetLengthMilliseconds());
  42. }
  43. else if (!_stricmp(data, "bitrate"))
  44. {
  45. if (info.Open(fn))
  46. StringCchPrintf(dest, destlen, L"%d", info.GetBitrate());
  47. }
  48. else if (!_stricmp(data, "title"))
  49. {
  50. return 1;
  51. }
  52. else if (!_stricmp(data, "width"))
  53. {
  54. if (info.Open(fn))
  55. {
  56. int width;
  57. if (info.GetWidth(width))
  58. StringCchPrintf(dest, destlen, L"%d", width);
  59. }
  60. }
  61. else if (!_stricmp(data, "height"))
  62. {
  63. if (info.Open(fn))
  64. {
  65. int height;
  66. if (info.GetHeight(height))
  67. StringCchPrintf(dest, destlen, L"%d", height);
  68. }
  69. }
  70. else
  71. return 0;
  72. return 1;
  73. }
  74. return 0;
  75. }