스트림 우선 순위 지정 사용
[이 페이지와 연결된 기능인 Windows Media Format 11 SDK는 레거시 기능입니다. 원본 판독기 및 싱크 작성기에 의해 대체되었습니다. 원본 판독기 및 싱크 작성기는 Windows 10 및 Windows 11 최적화되었습니다. 가능한 경우 새 코드에서 Windows Media Format 11 SDK 대신 소스 판독기 및 싱크 기록기를 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
스트림 우선 순위를 사용하면 프로필의 스트림에 대한 우선 순위 순서를 지정할 수 있으므로 콘텐츠 재생을 더 많이 제어할 수 있습니다. 재생 중에 판독기 및 스트리밍 서버에서 대역폭 부족이 발생하면 중단 없는 재생을 제공하려면 샘플을 삭제해야 할 수 있습니다. 프로필에서 스트림 우선 순위 지정 개체를 사용하여 우선 순위 순서를 지정하면 샘플이 가장 낮은 우선 순위 스트림에서 먼저 삭제됩니다.
대역폭 공유 및 상호 제외 개체와 달리 스트림 우선 순위 지정 개체는 IWMStreamList 인터페이스를 사용하여 스트림 목록을 추적하지 않습니다. 대신 WM_STREAM_PRIORITY_RECORD 구조체의 배열을 사용해야 합니다. 구조체는 우선 순위의 내림차순으로 배열로 구성되어야 합니다. 스트림 번호를 보유하는 것 외에도 스트림 우선 순위 구조를 사용하면 스트림이 필수인지 여부를 지정할 수 있습니다. 목록의 위치에 관계없이 필수 스트림은 삭제되지 않습니다.
다음 예제 코드는 프로필에 스트림 우선 순위를 포함하는 방법을 보여줍니다. 이 프로필은 강사 연설의 오디오 스트림, 강사의 비디오 스트림 및 프레젠테이션 슬라이드를 캡처하는 비디오 스트림이 있는 교실 프레젠테이션을 위한 것입니다. 오디오 스트림이 가장 중요하며 필수입니다. 이미지가 일정하기 때문에 프레젠테이션 슬라이드의 우선 순위가 가장 낮으므로 여기에서 몇 프레임이 손실되고 큰 차이가 없습니다.
IWMProfileManager* pProfileMgr = NULL;
IWMProfile* pProfileTmp = NULL;
IWMProfile3* pProfile = NULL;
IWMStreamPrioritization* pPriority = NULL;
WM_STREAM_PRIORITY_RECORD StreamArray[3];
HRESULT hr = S_OK;
// Initialize COM.
hr = CoInitialize(NULL);
// Create a profile manager object.
hr = WMCreateProfileManager(&pProfileMgr);
// Create an empty profile.
hr = pProfileMgr->CreateEmptyProfile(WMT_VER_9_0, &pProfileTmp)
// Get the IWMProfile3 for the new profile, then release the old one.
hr = pProfileTmp->QueryInterface(IID_IWMProfile3, (void**)&pProfile);
pProfileTmp->Release();
pProfileTmp = NULL;
// Give the new profile a name and description.
hr = pProfile->SetName(L"Prioritization_Example");
hr = pProfile->SetDescription(L"Only for use with example code.");
// Create the first stream.
hr = pProfile->CreateNewStream(WMMEDIATYPE_Audio, &pStream);
// TODO: configure the stream as needed for the scenario.
// Set the stream number.
hr = pStream->SetStreamNumber(1);
// Give the stream a name for clarity.
hr = pStream->SetStreamName(L"Lecturer_Audio");
// Include the new stream in the profile.
hr = pProfile->AddStream(pStream);
// Release the stream configuration interface.
pStream->Release();
pStream = NULL;
// Repeat for the other two streams.
hr = pProfile->CreateNewStream(WMMEDIATYPE_Video, &pStream);
// TODO: configure the stream as needed for the scenario.
hr = pStream->SetStreamNumber(2);
hr = pStream->SetStreamName(L"Lecturer_Video");
hr = pProfile->AddStream(pStream);
pStream->Release();
pStream = NULL;
hr = pProfile->CreateNewStream(WMMEDIATYPE_Video, &pStream);
// TODO: configure the stream as needed for the scenario.
hr = pStream->SetStreamNumber(3);
hr = pStream->SetStreamName(L"Slide_Video");
hr = pProfile->AddStream(pStream);
pStream->Release();
pStream = NULL;
// Create a stream prioritization object.
hr = pProfile->CreateNewStreamPrioritization(&pPriority);
// Fill the array with data.
StreamArray[0].wStreamNum = 1;
StreamArray[0].fMandatory = TRUE;
StreamArray[1].wStreamNum = 2;
StreamArray[1].fMandatory = FALSE;
StreamArray[2].wStreamNum = 3;
StreamArray[2].fMandatory = FALSE;
// Assign the stream array to the stream prioritization object.
hr = pPriority->SetPriorityRecords(StreamArray, 3);
// Add the stream prioritization to the profile.
hr = pProfile->SetStreamPrioritization(pPriority);
// Release the stream prioritization object.
pPriority->Release();
pPriority = NULL;
// TODO: Save the profile to a string, and save the string to a file.
// For more information, see To Save a Custom Profile.
// Release the remaining interfaces.
pProfile->Release();
pProfile = NULL;
pProfileMgr->Release();
pProfileMgr = NULL;
관련 항목