| 51 | double UpdateTime; |
| 52 | |
| 53 | bool Configure(VideoBackendPlayer& player, VideoPlayerMF& playerMF, DWORD streamIndex) |
| 54 | { |
| 55 | PROFILE_CPU_NAMED("Configure"); |
| 56 | PROFILE_MEM(Video); |
| 57 | IMFMediaType *mediaType = nullptr, *nativeType = nullptr; |
| 58 | bool result = true; |
| 59 | |
| 60 | // Find the native format of the stream |
| 61 | HRESULT hr = playerMF.SourceReader->GetNativeMediaType(streamIndex, MF_SOURCE_READER_CURRENT_TYPE_INDEX, &nativeType); |
| 62 | if (FAILED(hr)) |
| 63 | { |
| 64 | VIDEO_API_MF_ERROR(GetNativeMediaType, hr); |
| 65 | goto END; |
| 66 | } |
| 67 | hr = playerMF.SourceReader->GetCurrentMediaType(streamIndex, &mediaType); |
| 68 | if (FAILED(hr)) |
| 69 | { |
| 70 | VIDEO_API_MF_ERROR(GetCurrentMediaType, hr); |
| 71 | goto END; |
| 72 | } |
| 73 | GUID majorType, subtype; |
| 74 | hr = mediaType->GetGUID(MF_MT_MAJOR_TYPE, &majorType); |
| 75 | if (FAILED(hr)) |
| 76 | { |
| 77 | VIDEO_API_MF_ERROR(GetGUID, hr); |
| 78 | goto END; |
| 79 | } |
| 80 | hr = mediaType->GetGUID(MF_MT_SUBTYPE, &subtype); |
| 81 | if (FAILED(hr)) |
| 82 | { |
| 83 | VIDEO_API_MF_ERROR(GetGUID, hr); |
| 84 | goto END; |
| 85 | } |
| 86 | |
| 87 | // Extract media information |
| 88 | if (majorType == MFMediaType_Video) |
| 89 | { |
| 90 | UINT32 width, height; |
| 91 | hr = MFGetAttributeSize(mediaType, MF_MT_FRAME_SIZE, &width, &height); |
| 92 | if (SUCCEEDED(hr)) |
| 93 | { |
| 94 | player.Width = player.VideoFrameWidth = width; |
| 95 | player.Height = player.VideoFrameHeight = height; |
| 96 | } |
| 97 | MFVideoArea videoArea; |
| 98 | hr = mediaType->GetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, (UINT8*)&videoArea, sizeof(MFVideoArea), NULL); |
| 99 | if (SUCCEEDED(hr) && videoArea.Area.cx > 0 && videoArea.Area.cy > 0) |
| 100 | { |
| 101 | // Video frame has different size in memory than for display (eg. 1080p video will use 1088 height due to H264 decoding) |
| 102 | player.Width = videoArea.Area.cx; |
| 103 | player.Height = videoArea.Area.cy; |
| 104 | } |
| 105 | uint64_t fpsValue; |
| 106 | hr = mediaType->GetUINT64(MF_MT_FRAME_RATE, &fpsValue); |
| 107 | if (SUCCEEDED(hr)) |
| 108 | { |
| 109 | player.FrameRate = (float)HI32(fpsValue) / (float)LO32(fpsValue); |
| 110 | } |
no test coverage detected