2014-10-15 05:13:14 +08:00
|
|
|
/*
|
|
|
|
* cocos2d-x http://www.cocos2d-x.org
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010-2011 - cocos2d-x community
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) Microsoft Open Technologies, Inc.
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
*/
|
2014-03-29 03:53:35 +08:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-10-15 05:13:14 +08:00
|
|
|
#include <wrl.h>
|
|
|
|
#include <xaudio2.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
ref class MediaStreamer
|
2014-03-29 03:53:35 +08:00
|
|
|
{
|
|
|
|
private:
|
2014-10-15 05:13:14 +08:00
|
|
|
WAVEFORMATEX m_waveFormat;
|
|
|
|
uint32 m_maxStreamLengthInBytes;
|
|
|
|
std::vector<byte> m_data;
|
|
|
|
UINT32 m_offset;
|
2015-05-16 09:17:52 +08:00
|
|
|
UINT32 m_dataLen;
|
|
|
|
Platform::String^ m_filename;
|
|
|
|
|
|
|
|
Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename);
|
|
|
|
Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename, uint32 from, uint32 length);
|
|
|
|
|
2014-10-15 05:13:14 +08:00
|
|
|
internal:
|
|
|
|
Windows::Storage::StorageFolder^ m_location;
|
|
|
|
Platform::String^ m_locationPath;
|
2014-03-29 03:53:35 +08:00
|
|
|
|
|
|
|
public:
|
2014-10-15 05:13:14 +08:00
|
|
|
virtual ~MediaStreamer();
|
2014-03-29 03:53:35 +08:00
|
|
|
|
2014-10-15 05:13:14 +08:00
|
|
|
internal:
|
2014-03-29 03:53:35 +08:00
|
|
|
MediaStreamer();
|
|
|
|
|
|
|
|
WAVEFORMATEX& GetOutputWaveFormatEx()
|
|
|
|
{
|
|
|
|
return m_waveFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT32 GetMaxStreamLengthInBytes()
|
|
|
|
{
|
2015-05-16 09:17:52 +08:00
|
|
|
return m_dataLen;
|
2014-03-29 03:53:35 +08:00
|
|
|
}
|
|
|
|
|
2015-05-16 09:17:52 +08:00
|
|
|
void Initialize(_In_ const WCHAR* url, bool lazy = false);
|
|
|
|
void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
|
|
|
|
void ReadChunk(uint8* buffer, uint32 from, uint32 length, uint32* bytesRead);
|
2014-03-29 03:53:35 +08:00
|
|
|
void Restart();
|
2014-06-19 19:45:49 +08:00
|
|
|
};
|