MediaStreamer.h 1.7 KB

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