Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[[ Player ]] Update Windows player control to use MediaFoundation #7358

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
4 changes: 2 additions & 2 deletions config/win32.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
'_CRT_SECURE_NO_DEPRECATE',
'_CRT_DISABLE_PERFCRIT_LOCKS',
'__LITTLE_ENDIAN__',
'WINVER=0x0601', # Windows 7
'_WIN32_WINNT=0x0601', # Windows 7
'WINVER=0x0608', # Windows 8
'_WIN32_WINNT=0x0608', # Windows 8
],

'target_conditions':
Expand Down
13 changes: 7 additions & 6 deletions docs/dictionary/property/enabledTracks.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Type: property
Syntax: set the enabledTracks of <player> to <tracksList>

Summary:
Specifies which tracks in a <QuickTime> movie are available to be
Specifies which tracks in a movie are available to be
played.

Associations: player

Introduced: 1.0

OS: mac, linux
OS: mac, windows, linux

Platforms: desktop, server

Expand All @@ -25,18 +25,19 @@ track ID (a positive <integer>).

Description:
Use the <enabledTracks> <property> to control the user's ability to play
a <QuickTime> movie.
a movie.

A movie can contain multiple tracks intended to be played at the same
time (for example, an audio and a video track), or tracks that are
separate (for example, an alternative audio track). You can list the
tracks in a movie using the tracks <property>.

Changes:
This property was removed from the Windows platform in version 8.1.0,
due to the change of player implementation from QuickTime to DirectShow.
This property was added to the Windows platform in version 9.7.0, due
to the change of player implementation from DirectShow to
MediaFoundation.

References: QuickTime (glossary), property (glossary), integer (keyword),
References: property (glossary), integer (keyword),
trackCount (property)

Tags: multimedia
Expand Down
6 changes: 4 additions & 2 deletions docs/dictionary/property/loadedTime.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Associations: player

Introduced: 6.7

OS: mac, windows
OS: mac

Platforms: desktop

Expand All @@ -27,7 +27,9 @@ Use the <loadedTime> <property> to find out up to which time a movie or
sound can be played.

Changes:
Support for this property on Windows was added in version 8.1.0.
Support for this property on Windows was removed in version 9.7.0 due
to the change of player implementation from DirectShow to
MediaFoundation.

References: property (glossary), player (keyword), looping (property),
endTime (property), showSelection (property), callbacks (property),
Expand Down
15 changes: 8 additions & 7 deletions docs/dictionary/property/trackCount.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Type: property
Syntax: get the trackCount of <player>

Summary:
Specifies the number of separate tracks in a <QuickTime> movie.
Specifies the number of separate tracks in a movie.

Associations: player

Introduced: 1.0

OS: mac, linux
OS: mac, windows, linux

Platforms: desktop, server

Expand All @@ -27,17 +27,18 @@ This property is read-only and cannot be set.

Description:
Use the <trackCount> <property> to loop through the tracks in a
<QuickTime> movie.
movie.

Each track of a QuickTime movie holds a different set of data, which may
Each track of a movie holds a different set of data, which may
consist of sound, video, or other data types. The <trackCount>
<property> specifies how many tracks there are.

Changes:
This property was removed from the Windows platform in version 8.1.0,
due to the change of player implementation from QuickTime to DirectShow.
This property was added to the Windows platform in version 9.7.0, due
to the change of player implementation from DirectShow to
MediaFoundation.

References: QuickTime (glossary), property (glossary), integer (keyword),
References: property (glossary), integer (keyword),
enabledTracks (property), tracks (property), mediaTypes (property),
nodes (property)

Expand Down
27 changes: 18 additions & 9 deletions docs/dictionary/property/tracks.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Type: property
Syntax: get the tracks of <player>

Summary:
Lists all the tracks in a <QuickTime> movie.
Lists all the tracks in a movie.

Associations: player

Introduced: 1.0

OS: mac, linux
OS: mac, windows, linux

Platforms: desktop, server

Expand All @@ -22,25 +22,34 @@ Value (enum):
The <tracks> is a list of tracks, one per <line>. Each <line> consists
of four <items>, separated by commas:
- the track ID (an integer)
- the track media type (for example, "audio", "video", or
"VR Panorama" )
- the track media type (a string)

This property is read-only and cannot be set

Description:
Use the <tracks> <property> to find out the contents of a <QuickTime>
movie.
Use the <tracks> <property> to find out the contents of a movie.

A movie can contain multiple tracks intended to be played at the same
time (for example, an audio and a video track), or tracks that are
separate (for example, an alternative audio track). You specify which
tracks are active using the enabledTracks <property>.

**Track media types**
The track media type may be one of the following values:
- "vide": Video data
- "soun": Audio data
- "muxx": Combined video & audio data stream
- "meta": File metadata (MacOS X only)
- "sbtl": Subtitle data
- "tmcd": Timecode data (MacOS X only)
- "clcp": Closed caption data (MacOS X only)

Changes:
This property was removed from the Windows platform in version 8.1.0,
due to the change of player implementation from QuickTime to DirectShow.
This property was added to the Windows platform in version 9.7.0, due
to the change of player implementation from DirectShow to
MediaFoundation.

References: QuickTime (glossary), property (glossary), items (keyword),
References: property (glossary), items (keyword),
line (keyword), duration (property), trackCount (property)

Tags: multimedia
Expand Down
26 changes: 26 additions & 0 deletions docs/notes/feature-windows_mediafoundation_player.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Windows MediaFoundation Player Control

Due to the recent decision by Apple to end support for QuickTime on
Windows, the player implementation on that platform has been replaced
with one based on DirectShow. This is a multimedia API that is
available by default on all versions of Windows supported by LiveCode.

The new implementation should function as a drop-in replacement for
the old one, though some properties are not yet implemented.

### Property Changes
On Windows, the behaviour of some properties of the player control have changed.

- The **tracks**, **trackCount**, and **enabledTracks** previousy did not work
on Windows but now do.
- The **loadedTime** property no longer works on Windows, but will be re-enabled
if possible in a subsequent release.

### Supported File Formats

Media format support in the new Windows player control depends on
which codecs are installed.

A list of the
[file formats and compression types available as standard](https://docs.microsoft.com/en-us/windows/win32/medfound/supported-media-formats-in-media-foundation)
on Windows is available in the Windows Dev Center documentation
2 changes: 1 addition & 1 deletion engine/engine-sources.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@
'src/w32flst.cpp',
'src/w32icon.cpp',
'src/w32image.cpp',
'src/w32-mf-player.cpp',
'src/w32misc.cpp',
'src/w32-ds-player.cpp',
'src/w32prefix.cpp',
'src/w32printer.cpp',
'src/w32relaunch.cpp',
Expand Down
3 changes: 3 additions & 0 deletions engine/kernel.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
'-lgdi32',
'-liphlpapi',
'-limm32',
'-lmf',
'-lmfplat',
'-lmfuuid',
'-lmscms',
'-lmsimg32',
'-lpsapi',
Expand Down
34 changes: 26 additions & 8 deletions engine/src/mac-av-player.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,28 @@ static Boolean AVAssetHasType(AVAsset *p_asset, NSString *p_type)
[t_playerItemTrack setEnabled:*(bool *)p_value];
}

MCPlatformPlayerMediaType MCAVMediaTypeToMCPlatformPlayerMediaType(NSString *p_av_type)
{
if ([p_av_type isEqualToString: AVMediaTypeVideo])
return kMCPlatformPlayerMediaTypeVideo;
else if ([p_av_type isEqualToString: AVMediaTypeAudio])
return kMCPlatformPlayerMediaTypeAudio;
else if ([p_av_type isEqualToString: AVMediaTypeMuxed])
return kMCPlatformPlayerMediaTypeMuxed;
else if ([p_av_type isEqualToString: AVMediaTypeText])
return kMCPlatformPlayerMediaTypeText;
else if ([p_av_type isEqualToString: AVMediaTypeSubtitle])
return kMCPlatformPlayerMediaTypeSubtitle;
else if ([p_av_type isEqualToString: AVMediaTypeClosedCaption])
return kMCPlatformPlayerMediaTypeClosedCaption;
else if ([p_av_type isEqualToString: AVMediaTypeMetadata])
return kMCPlatformPlayerMediaTypeMetadata;
else if ([p_av_type isEqualToString: AVMediaTypeTimecode])
return kMCPlatformPlayerMediaTypeTimecode;

MCUnreachableReturn((MCPlatformPlayerMediaType)0);
}

void MCAVFoundationPlayer::GetTrackProperty(uindex_t p_index, MCPlatformPlayerTrackProperty p_property, MCPlatformPropertyType p_type, void *r_value)
{
// PM-2015-03-23: [[ Bug 15052 ]] Get the value of the enabledTracks property from the AVPlayerItemTrack
Expand All @@ -1650,23 +1672,19 @@ static Boolean AVAssetHasType(AVAsset *p_asset, NSString *p_type)
case kMCPlatformPlayerTrackPropertyId:
*(uint32_t *)r_value = [t_asset_track trackID];
break;
case kMCPlatformPlayerTrackPropertyMediaTypeName:
{
NSString *t_mediaType;
t_mediaType = [t_asset_track mediaType];
MCStringCreateWithCFStringRef((CFStringRef)t_mediaType, *(MCStringRef*)r_value);
}
case kMCPlatformPlayerTrackPropertyMediaType:
*(MCPlatformPlayerMediaTypes*)r_value = MCAVMediaTypeToMCPlatformPlayerMediaType(t_asset_track.mediaType);
break;
case kMCPlatformPlayerTrackPropertyOffset:
{
CMTimeRange t_timeRange = [t_asset_track timeRange];
*(uint32_t *)r_value = CMTimeToLCTime(t_timeRange . start);
*(MCPlatformPlayerDuration *)r_value = CMTimeToLCTime(t_timeRange . start);
}
break;
case kMCPlatformPlayerTrackPropertyDuration:
{
CMTimeRange t_timeRange = [t_asset_track timeRange];
*(uint32_t *)r_value = CMTimeToLCTime(t_timeRange . duration);
*(MCPlatformPlayerDuration *)r_value = CMTimeToLCTime(t_timeRange . duration);
}
break;
case kMCPlatformPlayerTrackPropertyEnabled:
Expand Down
6 changes: 3 additions & 3 deletions engine/src/platform-player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ void MCPlatformCreatePlayer(bool dontuseqt, MCPlatformPlayerRef& r_player)
#endif

#ifdef TARGET_PLATFORM_WINDOWS
class MCWin32DSPlayer;
extern MCWin32DSPlayer *MCWin32DSPlayerCreate(void);
class MCWin32MFPlayer;
extern MCWin32MFPlayer *MCWin32MFPlayerCreate(void);
void MCPlatformCreatePlayer(bool dontuseqt, MCPlatformPlayerRef &r_player)
{
r_player = (MCPlatformPlayerRef)MCWin32DSPlayerCreate();
r_player = (MCPlatformPlayerRef)MCWin32MFPlayerCreate();
}
#endif

Expand Down
18 changes: 11 additions & 7 deletions engine/src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -1021,22 +1021,26 @@ enum MCPlatformPlayerMediaType
kMCPlatformPlayerMediaTypeVideoBit,
kMCPlatformPlayerMediaTypeAudioBit,
kMCPlatformPlayerMediaTypeTextBit,
kMCPlatformPlayerMediaTypeQTVRBit,
kMCPlatformPlayerMediaTypeSpriteBit,
kMCPlatformPlayerMediaTypeFlashBit,
kMCPlatformPlayerMediaTypeMuxedBit,
kMCPlatformPlayerMediaTypeSubtitleBit,
kMCPlatformPlayerMediaTypeClosedCaptionBit,
kMCPlatformPlayerMediaTypeTimecodeBit,
kMCPlatformPlayerMediaTypeMetadataBit,

kMCPlatformPlayerMediaTypeVideo = 1 << kMCPlatformPlayerMediaTypeVideoBit,
kMCPlatformPlayerMediaTypeAudio = 1 << kMCPlatformPlayerMediaTypeAudioBit,
kMCPlatformPlayerMediaTypeText = 1 << kMCPlatformPlayerMediaTypeTextBit,
kMCPlatformPlayerMediaTypeQTVR = 1 << kMCPlatformPlayerMediaTypeQTVRBit,
kMCPlatformPlayerMediaTypeSprite = 1 << kMCPlatformPlayerMediaTypeSpriteBit,
kMCPlatformPlayerMediaTypeFlash = 1 << kMCPlatformPlayerMediaTypeFlashBit,
kMCPlatformPlayerMediaTypeMuxed = 1 << kMCPlatformPlayerMediaTypeMuxedBit,
kMCPlatformPlayerMediaTypeSubtitle = 1 << kMCPlatformPlayerMediaTypeSubtitleBit,
kMCPlatformPlayerMediaTypeClosedCaption = 1 << kMCPlatformPlayerMediaTypeClosedCaptionBit,
kMCPlatformPlayerMediaTypeTimecode = 1 << kMCPlatformPlayerMediaTypeTimecodeBit,
kMCPlatformPlayerMediaTypeMetadata = 1 << kMCPlatformPlayerMediaTypeMetadataBit,
};

enum MCPlatformPlayerTrackProperty
{
kMCPlatformPlayerTrackPropertyId,
kMCPlatformPlayerTrackPropertyMediaTypeName,
kMCPlatformPlayerTrackPropertyMediaType,
kMCPlatformPlayerTrackPropertyOffset,
kMCPlatformPlayerTrackPropertyDuration,
kMCPlatformPlayerTrackPropertyEnabled,
Expand Down