Technical/MediaServer: media providers.txt

File media providers.txt, 6.1 KB (added by nielsm, 16 months ago)

Incomplete proposal for media provider protocol

Line 
1Media provider framework
2
3The application will communicate with a media provider over a socket
4connection, this can be an IP socket, a Unix socket, or something else. It is
5important that multiple connections can be established however, so a simple
6pipe might not work.
7
8
9Discovering providers
10
11Providers are discovered by listing all directoties containing them. There will
12generally be a directory in the installation containing system providers, and
13the user profile can also contain a directory with providers. An entry in a
14provider directory can be either an executable file or a text file.
15
16Executable files (known by the .exe extension in Windows, by the execute
17permission bit in Unix) are used as local providers. They will be run and
18queried on application startup, see below.
19
20Non-executable files contain the address of one or more remote servers that can
21be contected and queried.
22
23
24Contacting a local provider
25
26A local provider is, as mentioned, an executable file found in a provider
27directory. To contact a local provider, the executable is launched with
28a command line option specifying a socket provided by the application, that
29the provider must connect to. The connection established here will be the
30control connection for the provider session.
31
32The command line option can be one of:
33
34  tcp:<port>
35    The application is listening for a TCP/IP connection on the local
36    interface, on the specified port number. The port number is given in
37    decimal. Example:
38   
39      tcp:2345
40      The application is listening for a TCP/IP connection on localhost:2345
41
42  unix:<socket>
43    The application is listening for a connection on the given Unix socket.
44    The socket must be stream-oriented. Example:
45   
46      unix:/tmp/aegisub-01ab23cd
47      The application has created a stream-oriented socket at
48      /tmp/aegisub-01ab23cd and is expecting a connection to it.
49
50
51Contacting a remote provider
52
53A remove provider specification file is a plain text file with the address
54of one remote server per line.
55
56The format of a line is the address of the server, a space, and the TCP
57port number it is listening at. The address can be a name, an IPv4 address
58in dotted quad notation, or an IPv6 address enclosed in square brackets.
59
60
61Control connection
62
63The control protocol is text-based and command-oriented, inspired by FTP.
64(Unlike FTP, the protocol is not based on the Telnet protocol.)
65
66All action on the control line is initiated by the application, with the
67provider answering requests.
68
69Requests from the application are one-word commands with zero or more space-
70separated parameters following.
71
72Responses from the provider are numeric response codes followed by details.
73
74The control protocol is used to query available media, open a media, and
75request chunks of the media. The actual media data are transferred on
76auxillary data connections.
77
78
79Data connections
80
81Media data are transferred on one or more auxillary data connections,
82asynchronously from the control connection. Simple provider implementations
83are allowed to block the control connection while data are transferring
84however.
85
86Data connections do not need to use the same communication medium as the
87control connection. One could imagine designing a shared memory
88"connection" for data transfers on the local machine.
89
90Every data connection in a session has an associated number. Data connections
91can be kept alive even when not in use and re-used for subsequent transfers.
92
93Media data transferred on data connections are in binary format, negotiated
94by the application and provider. Generally, this will be an uncompressed
95format, such as PCM for audio, or uncompressed pixel data for video.
96Compression should only be used when necessary, i.e. over a slow network.
97
98Transfers on data connections are always from provider to application, no
99data will be flowing from application to provider. Transfers are initiated
100by requests on the control connection. When the transfer initiates, the
101provider will send a response denoting what data connection it is
102transferring on, and how many bytes are being transferred.
103
104
105Control protocol commands
106
107Command parameters follow these conventions:
108Parameters are separated by one space character. If a parameter value contains
109a space, the value must be enclosed in double quotes. Backslash is the escape
110character, and is used to escape double quotes and other backslashes.
111
112INDEX <resource-name>
113  Begin creation of an index for the named resource if it doesn't exist
114  already. If an index exists, list all available streams in it.
115
116OPEN <resource-name> <stream-id> [<stream-id> ...]
117  Open the given streams in the named resource. All streams required must
118  be listed in the OPEN command, further streams can't be opened after
119  the resource has been opened initially.
120
121LIST [<directory>]
122  Only allowed for providers that do not use the local file system.
123  Lists all resources in the given directory, or the root of the resource
124  tree is no directory is specified.
125
126GETOPT [<name>]
127  Get the value of the named option. If no option name is given, list all
128  known options and their values.
129
130SETOPT <name> [<value>]
131  Set the named option to the given value.
132  The provider may reject the change if the value is out of range or
133  otherwise invalid.
134  If no value is given, the option is reset to the default value.
135
136NEWDC <protocol> [options...]
137  Create a new data connection. The protocol can be "tcp", "unix" or
138  something else, and the options depend on the protocol.
139  The provider must attempt to connect to the socket the application is
140  listening on, and respond with the new connection id when it succeeds,
141  or respond with failure otherwise.
142
143CLOSEDC <connection-id>
144  Close the given data connection.
145
146GETDATA <stream-id> <connection-id> <start> [<end>]
147  Request media data from the given stream number to be sent on the given
148  data connection. The start is the first frame number to transmit.
149  If no end is given, only the start frame is transmitted, otherwise all
150  frames from start up to and including the end frame are transmitted.
151  For audio, frame numbers are sample numbers.