コード例 #1
0
HRESULT FttpSchemeHandler::WhenCreateByteStream(IMFAsyncResult*result) {
  auto hr = MFEndCreateFile(result, &http_stream);
  assert(!source_creator);
  if (SUCCEEDED(hr)) hr = BeginCreateMediaSource();

  if (FAILED(hr)) {
    caller_result->SetStatus(hr);
    hr = MFInvokeCallback(caller_result.Get());
  }
  return S_OK;
}
コード例 #2
0
HRESULT CPlayer::OpenURLAsync(const WCHAR *sURL)
{
	// 1. Create a new media session.
	// 2. Create the media source.

	// Create the media session.
	HRESULT hr = S_OK;
	CHECK_HR(hr = CreateSession());

	// Create the media source.
	CHECK_HR(hr = BeginCreateMediaSource(sURL, this, &m_pSourceResolver));

	/////MADE ASYNCHRONOUS
	m_state = OpenAsyncPending;
done:
	if (FAILED(hr))
		m_state = Closed;
	return hr;
}
コード例 #3
0
//create bytestream
//create media-source
HRESULT FttpSchemeHandler::BeginCreateObject(LPCWSTR url,
                                             DWORD flags,
                                             IPropertyStore* ,  // not used
                                             IUnknown**cancel_cookie,
                                             IMFAsyncCallback*callback,
                                             IUnknown*s) {
  if(cancel_cookie)
    *cancel_cookie = nullptr;

  if ((flags & MF_RESOLUTION_WRITE) || !(flags & MF_RESOLUTION_MEDIASOURCE))
    return E_INVALIDARG;
  if (caller_result)
    return E_FAIL;  // only one session allowed

  uri = fttp_resolver().resolve(url);
  auto hr = uri.validate() ? S_OK : E_INVALID_PROTOCOL_FORMAT;

  IMFSchemeHandlerPtr pthis(this);

  if (SUCCEEDED(hr)) hr = MFCreateAsyncResult(nullptr, callback, s, &caller_result);
  if (SUCCEEDED(hr) && uri.type == fttp_type::url)
    scatter_tar_file_handler().async_check(uri.true_url).then([this, pthis](scheme_check_result result) {
      assert(!http_stream && !source_creator);
      content_type = result.content_type;
      CopyMemory(magic, result.maigic, sizeof(magic));
      HRESULT hr = result.error; // (result.error < 0) ? (result.error | make_sure_negativei32) : S_OK;
      if (SUCCEEDED(hr) && (http_stream || source_creator)) hr = E_FAIL;
      if (SUCCEEDED(hr)) 
        hr = MakeAndInitialize<ProgressiveHttpStream, IMFByteStream>(&http_stream, result.url.c_str(), result.content_length);
      if (SUCCEEDED(hr)) hr = BeginCreateMediaSource();

      if (FAILED(hr)) {
        caller_result->SetStatus(hr);
        hr = MFInvokeCallback(caller_result.Get());
      }
    });
  else if (SUCCEEDED(hr)) {
    auto fp = uri.true_url;
    hr = MFBeginCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, fp.c_str(), &when_create_bytestream, nullptr, nullptr);
  } 
  return hr;
}