MediaStreamer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * cocos2d-x http://www.cocos2d-x.org
  3. *
  4. * Copyright (c) 2010-2011 - cocos2d-x community
  5. * Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  6. *
  7. * Portions Copyright (c) Microsoft Open Technologies, Inc.
  8. * All Rights Reserved
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
  16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and limitations under the License.
  18. */
  19. #pragma once
  20. #include <wrl.h>
  21. #include <xaudio2.h>
  22. #include <vector>
  23. ref class MediaStreamer
  24. {
  25. private:
  26. WAVEFORMATEX m_waveFormat;
  27. uint32 m_maxStreamLengthInBytes;
  28. std::vector<byte> m_data;
  29. size_t m_offset;
  30. size_t m_dataLen;
  31. Platform::String^ m_filename;
  32. Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename);
  33. Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename, uint32 from, uint32 length);
  34. internal:
  35. Windows::Storage::StorageFolder^ m_location;
  36. Platform::String^ m_locationPath;
  37. public:
  38. virtual ~MediaStreamer();
  39. internal:
  40. MediaStreamer();
  41. WAVEFORMATEX& GetOutputWaveFormatEx()
  42. {
  43. return m_waveFormat;
  44. }
  45. size_t GetMaxStreamLengthInBytes()
  46. {
  47. return m_dataLen;
  48. }
  49. void Initialize(_In_ const WCHAR* url, bool lazy = false);
  50. void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
  51. void ReadChunk(uint8* buffer, uint32 from, uint32 length, uint32* bytesRead);
  52. void Restart();
  53. };