Skip to content

Commit

Permalink
extended CreateFFmpegInteropMSSFromStream to take in an empty MSS
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarpente committed Jun 28, 2017
1 parent 21de274 commit affe07d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
40 changes: 34 additions & 6 deletions FFmpegInterop/Source/FFmpegInteropMSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ FFmpegInteropMSS::~FFmpegInteropMSS()
mutexGuard.unlock();
}

FFmpegInteropMSS^ FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions)
FFmpegInteropMSS^ FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions, MediaStreamSource^ mss)
{
auto interopMSS = ref new FFmpegInteropMSS();
if (FAILED(interopMSS->CreateMediaStreamSource(stream, forceAudioDecode, forceVideoDecode, ffmpegOptions)))
if (FAILED(interopMSS->CreateMediaStreamSource(stream, forceAudioDecode, forceVideoDecode, ffmpegOptions, mss)))
{
// We failed to initialize, clear the variable to return failure
interopMSS = nullptr;
Expand All @@ -104,6 +104,10 @@ FFmpegInteropMSS^ FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(IRandomAcce
return interopMSS;
}

FFmpegInteropMSS^ FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions)
{
return CreateFFmpegInteropMSSFromStream(stream, forceAudioDecode, forceVideoDecode, nullptr, nullptr);
}

FFmpegInteropMSS^ FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode)
{
Expand Down Expand Up @@ -179,13 +183,14 @@ HRESULT FFmpegInteropMSS::CreateMediaStreamSource(String^ uri, bool forceAudioDe

if (SUCCEEDED(hr))
{
this->mss = nullptr;
hr = InitFFmpegContext(forceAudioDecode, forceVideoDecode);
}

return hr;
}

HRESULT FFmpegInteropMSS::CreateMediaStreamSource(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions)
HRESULT FFmpegInteropMSS::CreateMediaStreamSource(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions, MediaStreamSource^ mss)
{
HRESULT hr = S_OK;
if (!stream)
Expand Down Expand Up @@ -257,6 +262,7 @@ HRESULT FFmpegInteropMSS::CreateMediaStreamSource(IRandomAccessStream^ stream, b

if (SUCCEEDED(hr))
{
this->mss = mss;
hr = InitFFmpegContext(forceAudioDecode, forceVideoDecode);
}

Expand Down Expand Up @@ -427,16 +433,38 @@ HRESULT FFmpegInteropMSS::InitFFmpegContext(bool forceAudioDecode, bool forceVid
{
if (videoStreamDescriptor)
{
mss = ref new MediaStreamSource(videoStreamDescriptor, audioStreamDescriptor);
if (mss)
{
mss->AddStreamDescriptor(videoStreamDescriptor);
mss->AddStreamDescriptor(audioStreamDescriptor);
}
else
{
mss = ref new MediaStreamSource(videoStreamDescriptor, audioStreamDescriptor);
}
}
else
{
mss = ref new MediaStreamSource(audioStreamDescriptor);
if (mss)
{
mss->AddStreamDescriptor(audioStreamDescriptor);
}
else
{
mss = ref new MediaStreamSource(audioStreamDescriptor);
}
}
}
else if (videoStreamDescriptor)
{
mss = ref new MediaStreamSource(videoStreamDescriptor);
if (mss)
{
mss->AddStreamDescriptor(videoStreamDescriptor);
}
else
{
mss = ref new MediaStreamSource(videoStreamDescriptor);
}
}
if (mss)
{
Expand Down
3 changes: 2 additions & 1 deletion FFmpegInterop/Source/FFmpegInteropMSS.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace FFmpegInterop
public ref class FFmpegInteropMSS sealed
{
public:
static FFmpegInteropMSS^ CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions, MediaStreamSource^ mss);
static FFmpegInteropMSS^ CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions);
static FFmpegInteropMSS^ CreateFFmpegInteropMSSFromStream(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode);
static FFmpegInteropMSS^ CreateFFmpegInteropMSSFromUri(String^ uri, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions);
Expand Down Expand Up @@ -89,7 +90,7 @@ namespace FFmpegInterop
private:
FFmpegInteropMSS();

HRESULT CreateMediaStreamSource(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions);
HRESULT CreateMediaStreamSource(IRandomAccessStream^ stream, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions, MediaStreamSource^ mss);
HRESULT CreateMediaStreamSource(String^ uri, bool forceAudioDecode, bool forceVideoDecode, PropertySet^ ffmpegOptions);
HRESULT InitFFmpegContext(bool forceAudioDecode, bool forceVideoDecode);
HRESULT CreateAudioStreamDescriptor(bool forceAudioDecode);
Expand Down

0 comments on commit affe07d

Please sign in to comment.