1
0

DSTrackSelector.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "DSTrackSelector.h"
  2. #include "main.h"
  3. #include "CWAAudioRenderer.h"
  4. #include "../Agave/Language/api_language.h"
  5. #include "resource.h"
  6. int DSTrackSelector::getNumAudioTracks()
  7. {
  8. if (nullfilter)
  9. return nullfilter->GetConnectedInputsCount();
  10. return 1;
  11. }
  12. void DSTrackSelector::enumAudioTrackName(int n, char *buf, int size)
  13. {
  14. char t[256] = {0};
  15. StringCchPrintfA(t, 256, WASABI_API_LNGSTRING(IDS_TRACK_X), n);
  16. int l = min(size, 255);
  17. lstrcpynA((char *)buf, t, l);
  18. }
  19. int DSTrackSelector::getCurAudioTrack()
  20. {
  21. if (nullfilter)
  22. return nullfilter->GetSelectedInput();
  23. return 0;
  24. }
  25. int DSTrackSelector::getNumVideoTracks()
  26. {
  27. return 1;
  28. }
  29. void DSTrackSelector::enumVideoTrackName(int n, char *buf, int size)
  30. {
  31. WASABI_API_LNGSTRING_BUF(IDS_TRACK_1,buf,min(7, size));
  32. }
  33. int DSTrackSelector::getCurVideoTrack()
  34. {
  35. return 0;
  36. }
  37. void DSTrackSelector::setAudioTrack(int n)
  38. {
  39. if (nullfilter)
  40. {
  41. CComPtr<IMediaPosition> pMediaPosition = NULL;
  42. pGraphBuilder->QueryInterface(IID_IMediaPosition, (void **)&pMediaPosition);
  43. pMediaControl->Pause();
  44. REFTIME pos;
  45. pMediaPosition->get_CurrentPosition(&pos);
  46. nullfilter->SetSelectedInput(n);
  47. {
  48. CMediaType *mt = nullfilter->GetAcceptedType();
  49. if (mt->subtype != MEDIASUBTYPE_PCM)
  50. has_audio = NULL;
  51. else
  52. {
  53. WAVEFORMATEX *pHeader = (WAVEFORMATEX*)mt->pbFormat;
  54. // reget this cause this is the real UNCOMPRESSED format
  55. audio_bps = pHeader->wBitsPerSample;
  56. audio_srate = pHeader->nSamplesPerSec;
  57. audio_nch = pHeader->nChannels;
  58. if (audio_bps == 32 || audio_bps == 64)
  59. {
  60. m_float = 1;
  61. m_src_bps = audio_bps;
  62. audio_bps = 16; //TODO: read bits from AGAVE_API_CONFIG :)
  63. }
  64. }
  65. mod.outMod->Close();
  66. int maxlat = mod.outMod->Open(audio_srate, audio_nch, audio_bps, -1, -1);
  67. if (maxlat < 0)
  68. {
  69. releaseObjects();
  70. return ;
  71. }
  72. mod.SetInfo(m_bitrate, audio_srate / 1000, audio_nch, 1);
  73. mod.SAVSAInit(maxlat, audio_srate);
  74. mod.VSASetInfo(audio_srate, audio_nch);
  75. mod.outMod->SetVolume( -666);
  76. }
  77. pMediaPosition->put_CurrentPosition(pos);
  78. pMediaControl->Run();
  79. }
  80. }
  81. void DSTrackSelector::setVideoTrack(int n){}