Beruflich Dokumente
Kultur Dokumente
Programming Guide
Tiger
Contents
Introduction
Chapter 1
Concepts 15
Server Architecture 16
Modules 17
Protocols 18
Data 19
Classes 19
Applications and Tools 20
Source Organization 22
Server Preference Naming 24
Requirements for Modules 24
Main Routine 24
Dispatch Routine 25
Overview of QuickTime Streaming Server Operations 25
Server Startup and Shutdown 25
RTSP Request Processing 26
Runtime Environment for QTSS Modules 30
Server Time 31
Naming Conventions 31
Module Roles 32
Register Role 33
Initialize Role 33
Shutdown Role 34
Reread Preferences Role 35
Error Log Role 35
RTSP Roles 36
RTP Roles 41
RTCP Process Role 43
QTSS Objects 44
qtssAttrInfoObjectType 44
qtssClientSessionObjectType 45
qtssConnectedUserObjectType 47
3
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C O N T E N T S
qtssDynamicObjectType 48
qtssFileObjectType 49
qttsModuleObjectType 49
qtssModulePrefsObjectType 50
qtssPrefsObjectType 58
qtssRTPStreamObjectType 69
qtssRTSPHeaderObjectType 72
qtssRTSPRequestObjectType 72
qtssRTSPSessionObjectType 75
qtssServerObjectType 76
qtssTextMessageObjectType 80
qtssUserProfileObjectType 82
QTSS Streams 83
QTSS Services 85
Built-in Services 86
Automatic Broadcasting 86
Automatic Broadcasting Scenarios 86
ANNOUNCE Requests and SDP 88
Access Control of Announced Broadcasts 88
Broadcaster-to-Server Example 89
Additional Trace Examples 91
Stream Caching 98
Speed RTSP Header 99
x-Transport-Options Header 99
RTP Payload Meta-Information 100
x-Packet-Range RTSP Header 105
Reliable UDP 106
Acknowledgment Packets 106
RTSP Negotiation 107
Tunneling RTSP and RTP Over HTTP 107
HTTP Client Request Requirements 108
HTTP Server Reply Requirements 109
RTSP Request Encoding 110
Connection Maintenance 111
Support For Other HTTP Features 111
Chapter 2
Tasks 113
Building the Streaming Server 113
Mac OS X 113
POSIX 113
Windows 114
Building a QuickTime Streaming Server Module 114
Compiling a QTSS Module into the Server 114
Building a QTSS Module as a Code Fragment 114
Debugging 115
4
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C O N T E N T S
5
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C O N T E N T S
QTSS_IDForAttr 154
QTSS_RemoveInstanceAttribute 154
QTSS_RemoveValue 155
QTSS_SetValue 156
QTSS_SetValuePtr 156
QTSS_StringToValue 157
QTSS_TypeStringToType 158
QTSS_TypeToTypeString 158
QTSS_ValueToString 159
Stream Callback Routines 160
QTSS_Advis 160
QTSS_Read 160
QTSS_Seek 161
QTSS_RequestEvent 162
QTSS_SignalStream 162
QTSS_Write 163
QTSS_WriteV 164
QTSS_Flush 165
File System Callback Routines 165
QTSS_OpenFileObject 165
QTSS_CloseFileObject 166
Service Callback Routines 166
QTSS_AddService 166
QTSS_IDForService 167
QTSS_DoService 167
RTSP Header Callback Routines 168
QTSS_AppendRTSPHeader 168
QTSS_SendRTSPHeaders 169
QTSS_SendStandardRTSPResponse 169
RTP Callback Routines 170
QTSS_AddRTPStream 170
QTSS_Play 171
QTSS_Pause 172
QTSS_Teardown 172
Chapter 4
6
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C O N T E N T S
QTSS_RTPTransportType 180
QTSS_RTSPSessionType 180
QTSS_ServerState 180
Chapter 5
7
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C O N T E N T S
8
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Concepts 15
Figure 1-1
Figure 1-2
Figure 1-3
Figure 1-4
Figure 1-5
Figure 1-6
Figure 1-7
Figure 1-8
Figure 1-9
Figure 1-10
Figure 1-11
Figure 1-12
Figure 1-13
Figure 1-14
Listing 1-1
Table 1-1
Table 1-2
Table 1-3
Table 1-4
Table 1-5
Table 1-6
Table 1-7
Table 1-8
Table 1-9
Table 1-10
Table 1-11
Table 1-12
Table 1-13
Table 1-14
Table 1-15
Table 1-16
Table 1-17
Table 1-18
Table 1-19
Table 1-20
Table 1-21
Server architecture 16
Server object data model 20
QuickTime Streaming Server startup and shutdown 26
Sample RTSP request 27
Summary of RTSP request processing 28
Summary of the RTSP Preprocessor and RTSP Request roles 30
Pull-then-push automatic broadcasting 87
Listen-then-push automatic broadcasting 87
Standard RTP payload meta-information format 102
RTP data in standard format 103
Compressed RTP payload meta-information format 104
Mixed RTP payload meta-information format 104
Reliable UDP acknowledgment packet format 107
Required connections for tunneling 108
Starting a service 85
Module roles 32
Attributes of objects of type qtssAttrInfoObjectType 44
Attributes of objects of type qtssClientSessionObjectType 45
Attributes of objects of type qtssConnectedUserObjectType 48
Attributes of objects of type qtssFileObjectType 49
Attributes of objects of type qtssModuleObjectType 50
Attributes for preferences of the module QTSSAccessLogModule 50
Attributes for preferences of the module QTSSAccessModule 51
Attributes for preferences of the module QTSSAdminModule 51
Attributes for preferences of the module QTSSFileModule 52
Attributes for preferences of the module QTSSFlowControlModule 53
Attributes for preferences of the module QTSSHomeDirectoryModule 54
Attributes for preferences of the module QTSSMP3StreamingModule 54
Attributes for preferences of the module QTSSReflectorModule 55
Attributes for preferences of the module QTSSRefMovieModule 58
Attributes for preferences of the module QTSSRelayModule 58
Attributes of objects of type qtssPrefsObjectType 59
Attributes of objects of type qtssRTPStreamObjectType 69
Attributes of type qtssRTSPRequestObjectType 73
Attributes of objects of type qtssRTSPSessionObjectType 75
Attributes of objects of type qtssServerObjectType 77
9
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
T A B L E S ,
Table 1-22
Table 1-23
Table 1-24
Table 1-25
Table 1-26
Chapter 2
F I G U R E S ,
A N D
L I S T I N G S
Tasks 113
Listing 2-1
Listing 2-2
Listing 2-3
Listing 2-4
Listing 2-5
Listing 2-6
Listing 2-7
Listing 2-8
10
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
I N T R O D U C T I O N
Framework:
None.
Header:
QTSS.h
This chapter describes the callback rotuines and data types that modules use to call the QuickTime
Streaming Server.
This manual describes version 5.0 of the programming interface for creating QuickTime Streaming
Server (QTSS) modules for the open source Darwin Streaming Server. The QTSS programming
interface provides an easy way for developers to add new functionality to the Streaming Server. This
version of the programming interface is compatible with QuickTime Streaming Server version 5.5.
Whats New
Version 5.0 of the QTSS programming interface provides the following new features:
These new preferences have been added to the QTSSFileModule module for compatibility with
3rd Generation Partnership Project (3GPP) players:
compatibility_adjust_sdp_media_bandwidth_percent and enable_player_compatibility.
RTP play information is now enabled by default in the QTSSReflectorModule module. Use the
new preference, disable_rtp_play_info to disable RTP Play information. Another new
QTSSReflectorModule preference is reflector_rtp_info_offset_msec. For compatibility with
3GPP players, these preferences have also been added to the QTSSReflectorModule module:
enable_play_response_range_header, enable_player_compatibility, and
force_rtp_info_sequence_and_time.
Whats New
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
11
I N T R O D U C T I O N
The enable_rtp_play_info preference has been removed from the QTSSReflectorModule module.
The -D command line option has been added to the StreamingServer. When specified, the -D option
outputs performance status information.
The file streamingloadtool.conf, installed in /Library/QuickTimeStreaming/Config, has new
file tags:
playertext, where text is the name of the RTSP player. The information is sent to the server as
sendoptionssetting, where setting is yes or no. If yes, a Send Options request is made before the
DESCRIBE statement.
requestrandomdatasetting, where setting is yes or no. Set setting to yes to ask for random data
randomdatasizesetting, where setting is a number from 0 to 262144 that specifies the number of
Important: Text set off in this mannerwith the word Importantpresents important information
or instructions.
Warning: Text set off in this mannerwith the word Warningindicates potentially serious
problems.
12
AboutTheSource.html
DevNotes.html
I N T R O D U C T I O N
SourceCodeFAQ.html
The following RFCs provide additional information of interest to developers of QuickTime Streaming
Server modules and are available at many locations on the Internet:
For an overview of the Darwin Streaming Server and links to the latest QuickTime information, go
to http://developer.apple.com/darwin/projects/streaming.
Go to http://developer.apple.com/documentation/quicktime for QuickTime developer
documentation.
Communicate with other Darwin Streaming Server developers by joining the discussion list at
http://lists.apple.com/mailman/listinfo/streaming-server-dev.
See what with other Darwin Streaming Server developers are doing by joining the discussion list at
http://lists.apple.com/mailman/listinfo/publicsource-modifications.
13
I N T R O D U C T I O N
14
C H A P T E R
Concepts
This manual describes version 4.0 of the programming interface for creating QuickTime Streaming
Server (QTSS) modules. This version of the programming interface is compatible with QuickTime
Streaming Server version 5.
QTSS is an open-source, standards-based streaming server that runs on Windows NT and Windows
2000 and several UNIX implementations, including Mac OS X, Linux, FreeBSD, and the Solaris
operating system. To use the programming interface for the QuickTime Streaming Server, you should
be familiar with the following Internet Engineering Task Force (IETF) protocols that the server
implements:
This manual describes how to use the QTSS programming interface to develop QTSS modules for
the QuickTime Streaming Server. Using the programming interface described in this manual allows
your application to take advantage of the servers scalability and protocol implementation in a way
that will be compatible with future versions of the QuickTime Streaming Server. Most of the core
features of the QuickTime Streaming Server are implemented as modules, so support for modules
has been designed into the core of the server.
You can use the programming interface to develop QTSS modules that supplement the features of
the QuickTime Streaming server. For example, you could write a module that
acts as an RTSP proxy, which would be useful for streaming clients located behind a firewall
supports virtual hosting, allowing a single server to serve multiple domains from multiple
document roots.
15
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Server Architecture
The Streaming Server consists of one parent process that forks a child process, which is the core server.
The parent process waits for the child process to exit. If the child process exits with an error, the parent
process forks a new child process.
The core server acts as an interface between network clients, which use RTP and RTSP to send requests
and receive responses, and server modules, which process requests and send packets to the client.
The core server does its work by creating four types of threads:
the servers own Main thread. The Main thread checks to see if the server needs to shut down,
log status information, or print statistics.
the Idle Task thread. The Idle Task thread manages a queue of tasks that occur periodically. There
are two types of task queues: timeout tasks and socket tasks.
the Event thread. The Event thread listens for socket events such as a received RTSP request or
RTP packet and forwards them to a Task thread.
one or more Task threads. Tasks threads receive RTSP and RTP requests from the Event thread.
Tasks threads foward requests to the appropriate server module for processing and send packets
to the client. By default, the core server creates one Task thread per processor.
Figure 1-1 summarizes the relationship between clients, the core servers threads, and server modules.
Figure 1-1
Server architecture
Clients
Core Server
Modules
Main
thread
Idle
Task
thread
Task
queue
Idle
task
Task
queue
Process
Request
Task
Event
thread
Task
threads
Send
packets
task
Because the server is largely asynchronous, there needs to be a communication mechanism for events.
For instance, when a socket used for an RTSP connection gets data, something has to be notified so
that data can be processed. The Task object is a generalized mechanism for performing this
communication.
16
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Each Task object has two major methods: Signal and Run. Signal is called by the server to send an
event to a Task object. Run is called to give time to the Task for processing the event.
The goal of each Task object is to implement server functionality using small non-blocking time slices.
Run is a pure virtual function that is called when a Task object has events to process. Inside the Run
function, the Task object can call GetEvents to receive and automatically dequeue all its current and
previously signaled events. The Run function is never re-entered: if a Task object calls GetEvents in
its Run function, and is then signaled before the Run function completes, the Run function will be
called again for the new event only after exiting the function. In fact, the Tasks Run function will be
called repeatedly until the all the Task objects events have been cleared with GetEvents.
This core concept of event-triggered tasks is integrated into almost every Streaming Server subsystem.
For example, a Task object can be associated with a Socket object. If the Socket gets an event (through
a select() notification or through the Mac OS X Event Queue, the corresponding Task object will be
signaled. In this case, the body of the Run function will contain the code for processing whatever
event was received on that Socket.
Task objects make it possible for the Streaming Server use a singlethread to run all connections, which
is the Streaming Servers default configuration on a single processor system.
Modules
The Streaming Server uses modules to respond to requests and complete tasks. There are three types
of modules:
Content-Managing Modules
The content-managing modules manage RTSP requests and responses related to media sources, such
as a file or a broadcast. Each module is responsible for interpreting the clients request, reading and
parsing their supported files or network source, and responding with RTSP and RTP. In some cases,
such as the mp3 streaming module, the module uses HTTP.
The content-managing modules are QTSSFileModule, QTSSReflectorModule, QTSSRelayModule,
and QTSSMP3StreamingModule.
Server-Support Modules
The server-support modules perform server data gathering and logging functions. The server-support
modules are QTSSErrorLogModule, QTSSAccessLogModule, QTSSWebStatsModule,
QTSSWebDebugModule, QTSSAdminModule, and QTSSPOSIXFileSystemModule.
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
17
C H A P T E R
Concepts
Protocols
The Streaming Server supports the following protocols:
RTSP over TCP. The Real Time Streaming Protocol (RTSP) is a client-server multimedia
presentation control protocol designed to provide efficient delivery of streamed multimedia over
IP networks. RTSP provides a basis for negotiating unicast and multicast transport protocols,
such as RTP, and negotiates codecs in a file format independent way. It works well for large
audiences as well as single-viewer media-on-demand. RFC 2326 defines the IETF standard for
RTSP.
RTP over UDP. The Realtime Transport Protocol (RTP) is a packet format for multimedia data
streams. RTP is used by many standard protocols, such as RTSP for streaming applications and
SDP for multicast applications. It provides the data delivery format for RTSP and SDP. RFC 1889
defines the IETF proposed standard for RTP.
RTP over Apples Reliable UDP. If an RTP client requests it, the server sends RTP packets using
Reliable UDP. Reliable UDP is a set of quality of service enhancements, such as congestion control
tuning improvements, retransmit, and thinning server algorithms, that improve the ability to
present a good quality RTP stream to RTP clients even in the presence of packet loss and network
congestion. For more information, see Reliable UDP (page 106).
RTSP/RTP in HTTP (tunneled). Firewalls often prevent users on private IP networks from
receiving QuickTime presentations. On private networks, an HTTP proxy server is often configured
to provide users with indirect access to the Internet. To reach such clients, QuickTime 4.1 supports
the placement of RTSP and RTP data in HTTP requests and replies, allowing viewers behind
firewalls to access QuickTime presentations through HTTP proxy servers. For more information,
see Tunneling RTSP and RTP Over HTTP (page 107).
RTP over RTSP (RTP over TCP). Certain firewall designs and other circumstances may require
a server to use alternative means to send data to clients. RFC 2326 allows RTSP packets destined
for the same control end point to be packed into a single lower-layer protocol data unint (PDU),
encapsulated into a TCP stream, or interleaved with RTP and RTCP packets. Interleaving
complicates client and server operation and imposes additional overhead and should only be
used if RTSP is carried over TCP. RTP packets are encapsulated by an ASCII dollar sign ($),
followed by a one-byte channel identifier (defined in the transport header using the interleaved
parameter), followed by the length of the encapsulated binary data as a binary, two-byte integer
in network byte order. The stream data follows immediately, without a CRLF, but including the
upper-layer protocol headers. Each $ block contains exactly one RTP packet. When the transport
is RTP, RTCP messages are also interleaved by the server over the TCP connection. By default,
RTCP packets are sent on the first available channel higher than the RTP channel. The client may
request RTCP packets on another channel explicitly. This is done by specifying two channels in
the interleaved parameter of the transport header. RTCP is used for synchronization when two
or more streams are interleaved. Also, this provides a convenient way to tunnel RTP/RTCP
packets through the TCP control connection when required by the network configuration and
transfer them onto UDP when possible.
18
QTSSAdminModule
QTSSMP3StreamingModule
QTSSWebStatsModule
QTSSHTTPStreamingModule
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
QTSSRefMovieModule
QTSSWebStats
QTSSWebDebugModule
Data
When a module needs access to a requests RTSP header, it gains access to the request through a
request object defined by the QTSS.h API header file. For example, the RTSPRequestInterface class
implements the API dictionary elements accessible by the API. Objects whose name ends with
Interface, such as RTSPRequestInterface, RTSPSessionInterface, and QTSServerInterface, implement
the modules API.
The following interface classes are significant:
QTSServerInterface This is the internal data storage object tagged as the QTSS_ServerObject
in the API. Each of the QTSS_ServerAttributes in the API is declared and implemented in this
base class.
Classes
Figure 1-2 shows how the objects in the server reference each other.
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
19
C H A P T E R
Concepts
Figure 1-2
Server
preferences
Client
sessions
Modules
Module
preferences
RTSP
session
RTP
streams
The server object has a a dictionary of preferences. The server owns a list of modules each with a
dictionary for their preferences. The server owns a list of RTP client sessions, each of which can have
an RTSP session and one or more RTP media streams. It is possible to use the API to walk all of the
servers the live sessions and streams.
QTServer is the core server object, some of which is accessible through the API and the
QTSServerInterface base class.
Dictionary is a data storage base class that implements key and value access to object data. This
base class is inherited by all server objects defined by the API.
Module is a class for managing modules. Each module instance is responsible for loading,
initializing, and executing a static or dynamic API module.
RTSP and RTP sessions. Reads and writes are managed by the sessions through a stream object.
The RTSP session calls each of the modules in their registered RTSP role fromthe sessions
RTSPSession::Run method. The API module roles that are called are QTSS_RTSPFilter_Role,
QTSS_RTSPRoute_Role, QTSS_RTSPAuthenticate_Role, QTSS_RTSPAuthorize_Role,
QTSS_RTSPPreProcessor_Role, QTSS_RTSPRequest_Role, QTSS_RTSPPostProcessor_Role,
and QTSS_RTSPSessionClosingRole. The RTSP session also calls modules in their
QTSS_RTSPIncomingData_Role. The RTP session handles the following role calls as well as data
reads and writes: QTSS_RTPSendPackets_Role, QTSS_RTCPProcess_Role, and
QTSS_ClientSessionClosing_Role. For more information about roles, see Module
Roles (page 32).
20
PlayListBroadcaster
MP3Broadcaster
StreamingProxy
WebAdmin
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
qtpasswd
PlayListBroadcaster
PlaylistBroadcaster broadcasts QuickTime, MPEG4, and 3GPP streaming files to a streaming server,
such as QuickTime Streaming Server, which then reflects the media to clients. This lets you create a
virtual radio station or TV broadcast that appears to users as a live broadcast of the media.
MP3Broadcaster
The MP3Broadcaster application broadcasts an MP3 file as if it were a live broadcast.
StreamingProxy
POSIX and Mac OS X only.
QTFileTools
QTFileTools are movie-inspection utilities that use the QTFile library. The utillities are:
QTBroadcaster. This utility requires a target IP address, a source movie having one or more hint
track IDs, and an initial port. Every packet referenced by the hint track(s) is broadcast to the
specified IP address.
QTFileInfo. This utility requires a source movie. It displays the movies name, creation date, and
modification date. If the track is a hint track, the utility also displays the total RTP bytes and
packets, the average bit rate and packet size, and the total header percentage of the stream.
QTFileTest. This utility requires a source movie. It parses the Movie Header Atom and displays
a trace of the output.
QTRTPGent. This utility requires a source movie having a hint track ID. It displays the number
of packets in each hint track sample and writes the RTP packets to a file named track.cache.
QTRTPFileTest. This utility requires a source movie having a hint track ID. It displays the RTP
header (TransmitTime, Cookie, SeqNum, and TimeStamp) for each packet.
QTSampleLister. This utility requires a source movie and a track ID. It displays the track media
sample number, media time, data offset, and sample size for each sample in the track.
QTSDPGen. This utility requires a list of one or more source movies. It displays the SDP
information for all of the hinted tracks in each movie. Use the -f option to save the SDP information
to the file moviename.sdp in the same directory as the source movie.
QTTrackInfo. This utility requires a source movie, a sample table atom type (stco, stsc, stsz,
or stts) and a track ID. It displays the information in the sample table atom of the specified track.
The following example displays the chunk offset sample table in track 3:
./QTTrackInfo -T stco /movies/mystery/.mov 3
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
21
C H A P T E R
Concepts
WebAdmin
WebAdmin is a Perl-based web server. Connect a browser to it, and you can administer the server.
qtpasswd
The qtpasswd application generates password files for access control.
Source Organization
The Streaming Server source code is written entirely in C++ and pervasively uses object-oriented
concepts such as inheritance and polymorphism. Almost exclusively, there is one C++ class per .h /
.cpp file pair, and those file names match the class name.The Streaming Server source is organized
as follows:
Server.tproj
This directory contains the core server code, which can be divided into three subsystems:
22
Server core. Classes in this subsystem are prefixed by QTSS. QTSServer handles startup and
shutdown. QTSServerInterface stores server globals and compiles server statistics. QTSSPrefs is
a data store for server preferences. QTSSModule, QTSSModuleInterface, and QTSSCallbacks are
classes whose sole purpose is to support the QTSS module API.
RTSP subsystem. These classes handle the parsing and processing of RTSP requests, and implement
the RTSP part of the QTSS module API. Several of the classes correspond directly to elements of
the QTSS API (for instance, RTSPRequestInterface is a QTSS_RTSPRequestObject). There is one
RTSP session object per RTSP TCP connection. The RTSPSession object is a Task object that
processes RTSP related events.
RTP subsystem. These classes handle the sending of media data. The RTPSession object contains
the data associated with each RTSP session ID. Each RTPSession is a Task object that can be
scheduled to send RTP packets. The RTPStream object represents a single RTP stream. Any
number of RTPStream objects can be associated with a single RTPSession. These two objects
implement the RTP specific parts of the QTSS module API.
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
CommonUtilitiesLib
This directory contains a toolkit of thread management, data structure, networking, and text parsing
utilities. Darwin Streaming Server and associated tools use these classes to reduce repeated code by
abstracting similar or identical tasks, to simplify higher level code through encapsulation, and to
separate out platform-specific code. Here is a short description of the classes in the CommonUtilitiesLib
directory:
OS Classes. These classes provide platform-specific code abstractions for timing, condition
variables, mutexes, and threads. The classes are OS, OSCond, OSMutex, OSThread, and
OSFileSource. The data structures are OSQueue, OSHashTable, OSHeap, and OSRef.
Sockets. These classes provide platform-specific code abstractions for TCP and UDP networking.
Socket classes are generally asynchronous (or non-blocking), and can send events to Task objects.
The classes are EventContext, Socket, UDPSocket, UDPDemuxer, UDPSocketPool, TCPSocket,
and TCPListenerSocket.
Parsing Utilities. These classes parse and format text. The classes are StringParser, StringFormatter,
StrPtrLen, and StringTranslator.
QTFileLib
A major feature of the Streaming Server is its ability to serve hinted QuickTime movie files over RTSP
and RTP. This directory contains source code for the QTFile library, which contains all of the code
for parsing hinted QuickTime files. The servers RTPFileModule calls the QTFile library to retrieve
packets and meta-data from hinted QuickTime files. The QTFile library parses the following movie
file types: .mov, .mp4 (a modification of .mov), and .3gpp (a modification of .mov).
APICommonCode
This directory contains source code for API-related classes, such as moduletils, or common module
functions, such as log file management.
APIModules
This directory contains a directory for each Streaming Server module.
RTSPClientLib
This directory contains source code that implements the servers RTSP client, which can be used to
connect to the server using any of the supported protocols.
RTCPUtilitiesLib
This directory contains source code for parsing RTCP requests.
Server Architecture
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
23
C H A P T E R
Concepts
APIStubLib
This directory contains API definition and support files.
HTTPUtilitiesLib
This directory contains source code for parsing HTTP requests.
a main routine, which the server calls when it starts up to initialize the QTSS stub library with
your module
a dispatch routine, which the server uses when it calls the module for a specific purpose
Main Routine
Every QTSS modules must provide a main routine. The server calls the main routine as the server
starts up and uses it to initialize the QTSS stub library so the server can invoke your module later.
For modules that are compiled into the server, the address of the module's main routine must be
passed to the server's module initialization routine, as described in the section Compiling a QTSS
Module into the Server.
24
C H A P T E R
Concepts
where MyModuleDispatch is the name of the modules dispatch routine, which is described in the
following section, Dispatch Routine (page 25).
Important: For code fragment modules, the main routine must be named MyModule_Main where
MyModule is the name of the file that contains the module.
Dispatch Routine
Every QTSS module must provide a dispatch routine. The server calls the dispatch routine when it
invokes a module for a specific task, passing to the dispatch routine the name of the task and a
task-specific parameter block. (The programming interface uses the term role to describe specific
tasks. For information about roles, see Module Roles (page 32).)
The dispatch routine must have the following prototype:
void MyModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams);
where MyModuleDispatch is the name specified as the name of the dispatch routine by the modules
main routine, inRole is the name of the role for which the module is being called, and inParams is
a structure containing values of interest to the module.
25
C H A P T E R
Concepts
Figure 1-3
Shutdown
Server starts up
Server quits
When the server starts up, it first loads modules that are not compiled into the server (dynamic
modules) and then loads modules that are compiled into the server (static modules). If you are writing
a module that replaces existing server functionality, compile it as a dynamic module so that it is
loaded first.
Then the server invokes each QTSS module in the Register role, which is a role that every module
must support. In the Register role, the module calls QTSS_AddRole to specify the other roles that the
module supports.
Next, the server invokes the Initialize role for each module that has registered for that role. The
Initialize role performs any initialization tasks that the module requires, such as allocating memory
and initializing global data structures.
At shutdown, the server invokes the Shutdown role for each module that has registered for that role.
When handling the Shutdown role, the module should perform cleanup tasks and free global data
structures.
26
C H A P T E R
Concepts
Figure 1-4
When the server receives an RTSP request, it creates an RTSP request object, which is a collection of
attributes that describe the request. At this point, the qtssRTSPReqFullRequest attribute is the only
attribute that has a value and that value consists of the complete contents of the RTSP request.
Next, the server calls modules in specific roles according to a predetermined sequence. That sequence
is shown in Figure 1-5 (page 28).
27
C H A P T E R
Concepts
Note: The order in which the server calls any particular module for any particular role is undetermined.
Figure 1-5
Yes
Did a module
respond to the
client?
No
Did a module
respond to the
client?
No
Yes
No
Server calls module registered
for RTSP Request role
Done
When processing an RTSP request, the first role that the server calls is the RTSP Filter role. The server
calls each module that has registered for the RTSP Filter role and passes to it the RTSP request object.
Each modules RTSP Filter role has the option of changing the value of the qtssRTSPReqFullRequest
attribute. For example, an RTSP Filter role might change /foo/foo.mov to /bar/bar.mov, thereby
changing the folder that will be used to satisfy this request.
28
C H A P T E R
Concepts
Important: Any module handling the RTSP Filter role that responds to the client causes the server
to skip other modules that have registered for the RTSP Filter role, skip modules that have registered
for other RTSP roles, and immediately call the RTSP Postprocessor role of the responding module.
A response to a client is defined as any data the module may send to the client.
When all RTSP Filter roles have been invoked, the server parses the request. Parsing the request
consists of filling in the remaining attributes of the RTSP object and creating two sessions:
an RTSP session, which is associated with this particular request and closes when the client closes
its RTSP connection to the server
a client session, which is associated with the client connection that originated the request and
remains in place until the clients streaming presentation is complete
After parsing the request, the server calls the RTSP Route role for each module that has registered in
that role and passes the RTSP object. Each RTSP Route role has the option of using the values of
certain attributes to determine whether to change the value of the qtssRTSPReqRootDir attribute,
thereby changing the folder that is used to process this request. For example, if the language type is
French, the module could change the qtssRTSPReqRootDir attribute to a folder that contains the
French version of the requested file.
Important: Any module handling the RTSP Route role that responds to the client causes the server
to skip other modules that have registered for the RTSP Route role, skip modules that have registered
for other RTSP roles, and immediately calls the RTSP Postprocessor role of the responding module.
After all RTSP Route roles have been called, the server calls the RTSP Preprocessor role for each
module that has registered for that role. The RTSP Preprocessor role typically uses the
qtssRTSPReqAbsoluteURL attribute to determine whether the request matches the type of request
that the module handles.
If the request matches, the RTSP Preprocessor role responds to the request by calling QTSS_Write or
QTSS_WriteV to send data to the client. To send a standard response, the module can call
QTSS_SendStandardRTSPResponse, or QTSS_AppendRTSPHeader and QTSS_SendRTSPHeaders.
Important: Any module handling the RTSP Preprocessor role that responds to the client causes the
server to skip other modules that have registered for the RTSP Preprocessor role, skip modules that
have registered for other RTSP roles, and immediately calls the RTSP Postprocessor role of the
responding module.
If no RTSP Preprocessor role responds to the RTSP request, the server invokes the RTSP Request role
of the module that successfully registered for this role. (The first module that registers for the RTSP
Request role is the only module that can register for the RTSP Request role.) The RTSP Request role
is responsible for responding to all RTSP Requests that are not handled by modules registered for
the RTSP Preprocessor role.
After the RTSP Request role processes the request, the server calls modules that have registered for
the RTSP Postprocessor role. The RTSP Postprocessor role typically performs accounting tasks, such
as logging statistical information.
29
C H A P T E R
Concepts
A module handling the RTSP Preprocessor or RTSP Request role may generate the media data for a
particular client session. To generate media data, the module calls QTSS_Play, which causes that
module to be invoked in the RTP Send Packets role, as shown in Figure 1-6 (page 30).
Figure 1-6
No
Are there
more packets
to send?
Done
Yes
Return to server asking
to be called again
The RTP Send Packets role calls QTSS_Write or QTSS_WriteV to send data to the client over the RTP
session. When the RTP Send Packets role has sent some packets, it returns to the server and specifies
the time that is to elapse before the server calls the modules RTP Send Packets role again. This cycle
repeats until all of the packets for the media have been sent or until the client requests that the client
session be paused or torn down.
30
Perform tasks and return control to the server as quickly as possible. Returning quickly allows
the server to load balance among a large number of clients.
C H A P T E R
Concepts
Be prepared for QTSS_WouldBlock errors when performing stream I/O. The QTSS_Write,
QTSS_WriteV, and QTSS_Read callback routines return QTSS_WouldBlock if the requested I/O
would block. For more information about streams, see QTSS Streams (page 83).
Avoid using synchronous I/O wherever possible. An I/O operation that blocks may affect
streaming quality for other clients.
Server Time
The QuickTime Streaming Server handles real-time delivery of media, so many elements of QTSS
module programming interface are time values.
The servers internal clock counts the number of milliseconds that have elapsed since midnight,
January 1st, 1970. The data type QTSS_TimeVal is used to store the value of the servers internal clock.
To make it easy to work with time values, every attribute, parameter, and callback routine that deals
with time specifies the time units explicitly. For example, the qtssRTPStrBufferDelayInSecs attribute
specifies the clients buffer size in seconds. Unless otherwise noted, all time values are reported in
milliseconds from the servers internal clock using a QTSS_TimeVal data type.
To get the current value of the servers clock, call QTSS_Milliseconds or get the value of the
qtssSvrCurrentTimeMilliseconds attribute of the server object (QTSS_ServerObject). To convert
a time obtained from the servers clock to the current time, call QTSS_MilliSecsTo1970Secs.
Naming Conventions
The QTSS programming interface uses a naming convention for the data types that it defines. The
convention is to use the size of the data type in the name. Here are the data types that the QTSS
programming interface uses:
Parameters for callback functions defined by the QTSS programming interface follow these naming
conventions:
Parameters that are used for both input and output begin with io.
Naming Conventions
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
31
C H A P T E R
Concepts
Module Roles
Roles provide modules with a well-defined state for performing certain types of processing. A selector
of type QTSS_Role defines each role and represents the internal processing state of the server and the
number, accessibility, and validity of server data. Depending on the role, the server may pass to the
module one or more QTSS objects. In general, the server uses objects to exchange information with
modules. For more information about QTSS objects, see QTSS Objects (page 44).
Table 1-1 (page 32) lists the roles that this version of the QuickTime Streaming Server supports.
Table 1-1
Module roles
Name
Constant
Task
Register role
QTSS_Register_Role
Initialize role
QTSS_Initialize_Role
Shutdown role
QTSS_Shutdown_Role
Reread Preferences
role
QTSS_RereadPrefs_Role
QTSS_ErrorLog_Role
Logs errors.
QTSS_RTSPFilter_Role
QTSS_RTSPRoute_Role
RTSP Preprocessor
role
QTSS_RTSPPreProcessor_Role
QTSS_RTSPRequest_Role
RTSP Postprocessor
role
QTSS_RTSPPostProcessor_Role
Sends packets.
32
QTSS_RTCPProcess_Role
QTSS_OpenFilePreProcess_Role
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Name
Constant
Task
QTSS_OpenFile_Role
QTSS_AdviseFile_Role
QTSS_ReadFile_Role
Reads a file.
QTSS_RequestEventFile_Role
QTSS_CloseFile_Role
With the exception of the Register, Shutdown, and Reread Preferences roles, when the server invokes
a module for a role, the server passes to the module a structure specific to that particular role. The
structure contains information that the modules uses in the execution of that role or provides a way
for the module to return information to the server.
The RTSP roles have the option of responding to the client. A response is defined as any data that a
module sends to a client. Modules can send data to the client in a variety of ways. They can, for
example, call QTSS_Write or QTSS_WriteV.
Note: The order in which modules are called for any particular role is undetermined.
Register Role
Modules use the Register role to call QTSS_AddRole to tell the server the roles they support.
Modules also use the Register role to call QTSS_AddService to register services and to call
QTSS_AddStaticAttribute to add static attributes to QTSS object types. (QTSS objects are collections
of attributes, each having a value.)
The server calls a modules Register role once at startup. The Register role is always the first role that
the server calls.
A module that returns any value other than QTSS_NoErr from its Register role is not loaded into the
server.
Initialize Role
The server calls the Initialize role of those modules that have registered for this role after it calls the
Register role for all modules. Modules use the Initialize role to initialize global and private data
structures.
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
33
C H A P T E R
Concepts
The server passes to each modules Initialize role objects that can be used to obtain the servers global
attributes, preferences, and text error messages. The server also passes the error log stream reference,
which can be used to write to the error log. All of these objects are globals, so they are valid for the
duration of this run of the server and may be accessed at any time.
When called in the Initialize role, the module receives a QTSS_Initialize_Params structure which
is defined as follows:
typedef struct
{
QTSS_ServerObject
inServer;
QTSS_PrefsObject
inPrefs;
QTSS_TextMessagesObjectinMessages;
QTSS_ErrorLogStream inErrorLogStream;
QTSS_ModuleObject
inModule;
} QTSS_Initialize_Params;
inServer
A QTSS_ServerObject object containing the servers global attributes and an attribute that
contains information about all of the modules in the running server. For a description of each
attribute, see the section qtssServerObjectType (page 76).
inPrefs
A QTSS_TextMessagesObject object that a module can use for providing localized text strings.
See the section qtssTextMessageObjectType (page 80).
inErrorLogStream
A QTSS_ErrorLogStream stream reference that a module can use to write to the servers error
log. Writing to this stream causes the module to be invoked in its Error Log role.
inModule
A QTSS_ModuleObject object that a module can use to store information about itself, including
its name, version number, and a description of what the module does. See the section
qttsModuleObjectType (page 49).
A module that wants to be called in the Initialize role must in its Register role call QTSS_AddRole and
specify QTSS_Initialize_Role as the role.
A module that returns any value other than QTSS_NoErr from its Initialize role is not loaded into the
server.
Shutdown Role
The server calls the Shutdown role of those modules that have registered for this role when the server
is getting ready to shut down.
34
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
The server calls a modules Shutdown role without passing any parameters.
The module uses its Shutdown role to delete all data structures it has created and to perform any
other cleanup task
A module that wants to be called in the Shutdown role must in its Register role call QTSS_AddRole
and specify QTSS_Shutdown_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
The server guarantees that the Shutdown role is the last time that the module is called before the
server shuts down.
inVerbosity
Specifies the verbosity level of this error message. Modules should use the inFlags parameter
of QTSS_Write to specify the verbosity level. The following constants are defined:
qtssFatalVerbosity = 0, qtssWarningVerbosity = 1, qtssMessageVerbosity = 2,
qtssAssertVerbosity = 3, qtssDebugVerbosity = 4,
inBuffer
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
35
C H A P T E R
Concepts
Writing an error message at the level qtssFatalVerbosity causes the server to shut down
immediately.
Writing to the error log cannot result in an QTSS_WouldBlock error.
A module that wants to be called in the Error Log role must in its Register role call QTSS_AddRole
and specify QTSS_ErrorLog_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
RTSP Roles
When the server receives an RTSP request, it goes through a series of steps to process the request and
ensure that a response is sent to the client. The steps consist of calling certain roles in a predetermined
order. This section describes each role in detail. For an overview of roles and the sequence in which
they are called, see the section Overview of QuickTime Streaming Server Operations (page 25).
Note: All RTSP roles have the option of responding directly to the client. When any RTSP role responds
to a client, the server immediately skips the RTSP roles that it would normally call and calls the RTSP
Postprocessor role of the module that responded to the RTSP request.
inRTSPSession;
inRTSPRequest;
outNewRequest;
inRTSPSession
The QTSS_RTSPSessionObject object for this RTSP session. See the section
qtssRTSPSessionObjectType (page 75) for information about RTSP session object attributes.
inRTSPRequest
The QTSS_RTSPRequestObject object for this RTSP request. When called in the RTSP Filter
role, only the qtssRTSPReqFullRequest attribute has a value. See the section
qtssRTSPRequestObjectType (page 72) for information about RTSP request object attributes.
outNewRequest
A pointer to a location in memory.
36
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
The module calls QTSS_GetValuePtr to get from the qtssRTSPReqFullRequest attribute the complete
RTSP request that caused the server to call this role. The qtssRTSPReqFullRequest attribute is a
read-only attribute. To change the RTSP request, the module should call QTSS_New to allocate a buffer,
write the modified request into that buffer, and return a pointer to that buffer in the outNewRequest
field of the QTSS_StandardRTSP_Params structure.
While a module is handling the RTSP Filter role, the server guarantees that the module will not be
called for any other role referencing the RTSP session represented by inRTSPSession.
If module handling the RTSP Filter role responds directly to the client, the server next calls the
responding module in the RTSP Postprocessor role. For information about that role, see the section
RTSP Postprocessor Role (page 40).
A module that wants to be called in the RTSP Filter role must in its Register role call QTSS_AddRole
and specify QTSS_RTSPFilter_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
inRTSPSession;
inRTSPRequest;
inRTSPHeaders;
inClientSession;
inRTSPSession
The QTSS_RTSPSessionObject object for this RTSP session. See the section
qtssRTSPSessionObjectType (page 75) for information about RTSP session object attributes.
inRTSPRequest
The QTSS_RTSPRequestObject object for this RTSP request. In the Route role and all subsequent
RTSP roles, all of the attributes are filled in. See the section
qtssRTSPRequestObjectType (page 72) for information about RTSP request object attributes.
inRTSPHeaders
The QTSS_RTSPHeaderObject object for the RTSP headers. See the section
qtssRTSPHeaderObjectType (page 72) for information about RTSP header object attributes.
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
37
C H A P T E R
Concepts
Before calling modules in the RTSP Route role, the server parses the request. Parsing the request
consists of filling in all of the attributes of the QTSS_RTSPSessionObject and QTSS_RTSPRequestObject
members of the QTSS_StandardRTSP_Params structure.
A module processing the RTSP Route role has the option of changing the qtssRTSPReqRootDir
attribute of the QTSS_RTSPRequestObject member of the QTSS_StandardRTSP_Params structure.
Changing the qtssRTSPReqRootDir attribute changes the root folder for this RTSP request.
While a module is handling the RTSP Route role, the server guarantees that the module will not be
called for any other role referencing the RTSP session represented by inRTSPSession.
If a module that is processing the RTSP Route role responds directly to the client, the server
immediately skips the processing of any other roles and calls the responding modules RTSP
Postprocessor role. For information about that role, see the section RTSP Postprocessor
Role (page 40).
A module that wants to be called in the RTSP Route role must in its Register role call QTSS_AddRole
and specify QTSS_RTSPRoute_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
inRTSPSession
The QTSS_RTSPSessionObject object for this RTSP session. See the section
qtssRTSPSessionObjectType (page 75) for information about RTSP session object attributes.
inRTSPRequest
The QTSS_RTSPRequestObject object for this RTSP request with a value for each attribute.
See the section qtssRTSPRequestObjectType (page 72) for information about RTSP request
object attributes.
inRTSPHeaders
The QTSS_RTSPHeaderObject object for the RTSP headers. See the section
qtssRTSPHeaderObjectType (page 72) for information about RTSP header object attributes.
38
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
The RTSP Preprocessor role typically uses the qtssRTSPReqFilePath attribute of the inRTSPRequest
member of the QTSS_StandardRTSP_Params structure to determine whether the request matches the
type of request that the module handles. For example, a module may only handle URLs that end in
.mov or .sdp.
If the request matches, the module handling the RTSP Preprocessor role responds to the request by
calling QTSS_SendStandardRTSPResponse, QTSS_Write, or QTSS_WriteV, or by calling
QTSS_AppendRTSPHeader, and QTSS_SendRTSPHeaders. If this module is also responsible for generating
RTP packets for this client session, it should call QTSS_AddRTPStream (page 170) to add streams to the
client session, and QTSS_Play, which causes the server to invoke the RTP Send Packets role of the
module whose RTSP Preprocessor role calls QTSS_Play.
While a module is handling the RTSP Preprocessor role, the server guarantees that the module will
not be called for any other role referencing the RTSP session specified by inRTSPSession or the client
session specified by inClientSession.
A module that wants to be called in the RTSP Preprocessor role must in its Register role call
QTSS_AddRole and specify QTSS_RTSPPreProcessor_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
inRTSPSession;
inRTSPRequest;
inRTSPHeaders;
inClientSession;
inRTSPSession
The QTSS_RTSPSessionObject object for this RTSP session. See the section
qtssRTSPSessionObjectType (page 75) for information about RTSP session object attributes.
inRTSPRequest
The QTSS_RTSPRequestObject object for this RTSP request with a value for each attribute.
See the section qtssRTSPRequestObjectType (page 72) for information about RTSP request
object attributes.
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
39
C H A P T E R
Concepts
inRTSPHeaders
The QTSS_RTSPHeaderObject object for the RTSP headers. See the section
qtssRTSPHeaderObjectType (page 72) for information about RTSP header object attributes.
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
Like a module processing the RTSP Preprocessor role, a module that processes the RTSP Request
Role should use an attribute, such as the qtssRTSPReqFilePath attribute of the inRTSPRequest
member of the QTSS_StandardRTSP_Params structure, to determine whether the request matches the
type of request that the module can handle.
A module handling the RTSP Request role should respond to the request by
Preparing the QTSS_ClientSessionObject for streaming by using the RTP callbacks, such as
QTSS_AddRTPStream and QTSS_Play. If QTSS_Play is called, the server will invoke the calling
module in the RTP Send Packets role, at which time the module will be expected to generate RTP
packets to send to the client.
A module that wants to be called in the RTSP Request role must in its Register role call QTSS_AddRole
and specify QTSS_RTSPRequest_Role as the role. The first module that successfully calls QTSS_AddRole
and specifies QTSS_RTSPRequest_Role as the role is the only module that is called in the RTSP Request
role.
Modules should always return QTSS_NoErr when they finish handling this role.
inRTSPSession;
inRTSPRequest;
inRTSPHeaders;
inClientSession;
inRTSPSession
The QTSS_RTSPSessionObject object for this RTSP session. See the section
qtssRTSPSessionObjectType (page 75) for information about RTSP session object attributes.
40
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
inRTSPRequest
The QTSS_RTSPRequestObject object for this RTSP request with a value for each attribute.
See the section qtssRTSPRequestObjectType (page 72) for information about RTSP request
object attributes.
inRTSPHeaders
The QTSS_RTSPHeaderObject object for the RTSP headers. See the section
qtssRTSPHeaderObjectType (page 72) for information about RTSP header object attributes.
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
While a module is handling the RTSP Postprocessor role, the server guarantees that the module will
not be called for any role referencing the RTSP session specified by inRTSPSession or the client session
specified by inClientSession.
A module that wants to be called in the RTSP Postprocessor role must in its Register role call
QTSS_AddRole and specify QTSS_RTSPPostProcessor_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
RTP Roles
This section describes RTP roles, which are used to send data to clients and to handle the closing of
client sessions.
inClientSession;
inCurrentTime;
outNextPacketTime;
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
inCurrentTime
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
41
C H A P T E R
Concepts
outNextPacketTime
A time offset in milliseconds. Before returning from this role, a module should set
outNextPacketTime to the amount of time that the server should allow to elapse before calling
the RTP Send Packets role again for this session.
The RTP Send Packets role is invoked whenever a module calls QTSS_Play for that client session. The
module calls QTSS_Write or QTSS_WriteV to send data to the client.
While a module is handling the RTP Send Packets role, the server guarantees that the module will
not be called for any role referencing the client session specified by inClientSession.
A module that wants to be called in the RTP Send Packets role must in its Register role call
QTSS_AddRole and specify QTSS_RTPSendPackets_Role as the role.
Modules should always return QTSS_NoErr when they finish handling this role.
inReason
The reason why the session is closing. The session may be closing because the client sent an
RTSP teardown (qtssCliSesClosClientTeardown), because this session has timed out
(qtssCliSesClosTimeout), or because the client disconnected without issuing a teardown
(qtssCliSesClosClientDisconnect).
inClientSession
42
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
inRTPStream;
inClientSession;
inRTCPPacketData;
inRTCPPacketDataLen;
inRTPStream
The QTSS_RTPStreamObject object for the RTP stream that this RTCP packet belongs to. See
the section qtssRTPStreamObjectType (page 69) for information about RTP stream object
attributes.
inClientSession
The QTSS_ClientSessionObject object for the client session. See the section
qtssClientSessionObjectType (page 45) for information about client session object attributes.
inRTCPPacketData
Module Roles
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
43
C H A P T E R
Concepts
QTSS Objects
QTSS objects provide a way for modules and the server to exchange data with each other. QTSS
objects consist of attributes that are used to store data. Every attribute has a name, an attribute ID, a
data type, and permissions for reading and writing the attributes value. Built-in attributes are attributes
that the server always defines for an object type. For example, the QTSS_RTSPRequestObject object
has a built-in URL attribute that other modules can read to obtain the URL associated with a particular
RTSP request.
This section describes the attributes for each object type. The object types are
qtssAttrInfoObjectType
An object of type qtssAttrInfoObjectType consists of attributes whose values describe an attribute:
the attributes name, attribute ID, data type, and permissions for reading and writing the attributes
value. An attribute information object (QTSS_AttrInfoObject) is an instance of this object type. There
is one QTSS_AttrInfoObject for every attribute.
Table 1-2 (page 44) lists the attributes for objects of type qtssAttrInfoObjectType.
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-2
44
Access
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Data Type
C H A P T E R
Concepts
Access
Data Type
QTSS_AttrPermission
qtssClientSessionObjectType
An object of type qtssClientSessionObjectType consists of attributes that describe a client session,
where a client session is defined as a single client streaming presentation. A client session object
(QTSS_ClientSessionObject) is an instance of this object type. The attributes of a client session object
are valid for all roles that receive a value of type QTSS_ClientSessionObject in the structure the
server passes to them.
Table 1-3 (page 45) lists the attributes for objects of type qtssClientSessionObjectType.
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-3
Access
Data Type
safe
qtssCliSesCounterID A counter-based
rate.
safe
qtssCliSesFirstPlayTimeInMsec The
time in milliseconds at which QTSS_Play
safe
URL for this session. Same as the
qtssCliSesPresentationURL attribute but
includes the rtsp://domain_name prefix.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
45
C H A P T E R
Concepts
Access
Data Type
UInt32
Readable, writable,
preemptive safe
Float64
UInt64
qtssCliSesMovieAverageBitRate The
qtssCliSesMovieDurationInSecs
preemptive safe
safe
46
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
qtssCliSesTimeConnectedinMsec Time
Data Type
safe
safe
qtssCliRTSPSessRemoteAddrStr The IP
safe
safe
Readable, writable,
preemptive safe
reason. If not requested by the client, the
reason for the disconnection must be set by
the module that calls QTSS_Teardown.
qtssCliTeardownReason The teardown
QTSS_CliSesTeardownReason
qtssConnectedUserObjectType
An object of type qtssConnectedUserObjectType consists of attributes associated with a connected
user, irrespective of the transport. Users connecting to a QuickTime movie are already represented
by objects of type qtssClientSessionObjectType, so this object is used for other connected users,
such as those requesting MP3 streams.
A connected user object (QTSS_ConnectedUserObject) is an instance of this object type. A
QTSS_ConnectedUserObject can be created in any module. It can be added to the
qtssSvrConnectedUsers attribute of the QTSS_ServerObject (described in the section
qtssServerObjectType (page 76)).
Table 2-4 (page 48) lists the attributes for objects of type qtssConnectedUserObjectType.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
47
C H A P T E R
Concepts
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, QTSS_GetValuePtr.
Table 1-4
Access
Data Types
UInt32
bit rate in bits per second of all of the streams for this
session. This is not an average.
qtssConnectionHostName The host name of the
connected client.
qtssConnectionMountPoint Presentation URL for
such as MP3.
qtssConnectionSessLocalAddrStr Local IP address Readable, preemptive safe
char
qtssDynamicObjectType
An object of type qtssDynamicObjectType can be used to create an object that doesnt have any static
attributes.
48
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
qtssFileObjectType
An object of type qtssFileObject consists of attributes that describe a file that has been opened. A
file object (QTSS_FileObject) is an instance of this object type. These attributes are valid for all roles
that receive a QTSS_FileObject in the structure the server passes to them.
Table 1-5 (page 49) lists the attributes for objects of type qtssFileObjectType.
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-5
Access
Data Type
QTSS_StreamRef
file object.
qtssFlOjFileSysModuleName The name of the Readable, preemptive safe
char
UInt64
preemptive safe
Readable, writable,
bytes of the files file pointer from the beginning preemptive safe
of the file (byte zero).
UInt64
QTSS_TimeVal
preemptive safe
qttsModuleObjectType
An object of type qtssModuleObject consists of attributes that describe a particular QTSS module,
including its name, version number, a description of what the module does, its preferences, and the
roles the module is registered for. A module object (QTSS_ModuleObject) is an instance of this object
type. These attributes are valid for all roles that receive a QTSS_ModuleObject in the structure the
server passes to them.
For each module the server loads, the server creates a module object and passes it to the module in
the modules Initialize role. Modules can get information about other modules the server has loaded
by accessing the qtssSvrModuleObject attribute of the QTSS_ServerObject object.
In addition to the attributes that store the modules name, version number and description, this object
type has a module preferences attribute, qtssModPrefs. The qtssModPrefs attribute itself is an object
whose attributes store the modules preferences as instance attributes. All modifications to the
qtssModPrefs attribute are persistent between invocations of the server because the contents of each
modules qtssModPrefs attribute are written to the servers configuration file, which is read when
the server starts up.
Table 1-6 (page 50) lists the attributes for objects of type qtssModuleObjectType.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
49
C H A P T E R
Concepts
Note: With the exception of qtssModDesc and qtssModVersion, these attributes are preemptive safe
and can be read by calling QTSS_GetValue, QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-6
Access
Data Type
Readable, writable,
modules can use to store any local attributes preemptive safe
other than preferences.
qtssModAttributes An object that
QTSS_Object
module does.
char
UInt32
qtssModulePrefsObjectType
An object of type QTSS_ModulePrefsObject consists of attributes that contain a modules preferences.
A module preferences object QTSS_ModulePrefsObject) is an instance of this object type.
Each module is reponsible for adding attributes to its module preferences object and setting their
values. The values of the preferences in the module preferences object are persistent between
invocations of the server because the server writes the module preferences object for each module to
a configuration file that the server reads when it is started.
QTSSAccessLogModule Preferences
Table 1-7 (page 50) lists the attributes for preferences of the module QTSSAccessLogModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-7
50
Access
Data Type
Bool16
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
UInt32
attribute is 10240000.
preemptive safe
UInt32
Bool16
char
char
of this attribute is 7.
QTSSAccessModule Preferences
Table 1-8 (page 51) lists the attributes for preferences of the module QTSSAccessModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-8
Access
Data Type
char
preemptive safe
this attribute is
/Library/QuickTimeStreaming/Config/qtgroups.
char
char
this attribute is
/Library/QuickTimeStreaming/Config/qtusers.
QTSSAdminModule Preferences
Table 1-9 (page 51) lists the attributes for preferences of the module QTSSAdminModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-9
Access
Data Type
char
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
51
C H A P T E R
Concepts
Access
Data Type
Bool16
Bool16
char
Bool16
preemptive safe
UInt32
QTSSFileModule Preferences
Table 1-10 (page 52) lists the attributes for preferences of the module QTSSFileModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-10
Access
Data Type
Float32
preemptive safe
admin_email By default, this attribute does not have a value. Readable, writable, not
char
preemptive safe
compatibility_adjust_sdp_media_bandwidth_percent Readable, writable, not
Bool16
preemptive safe
Bool16
Bool16
Bool16
52
UInt32
preemptive safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
UInt32
Float32
UInt32
UInt32
UInt32
UInt32
UInt32
UInt32
Bool16
char
is 4.000000.
max_private_buffer_units_per_buffer By default, the
UInt32
preemptive safe
QTSSFlowControlModule Preferences
Table 1-11 (page 53) lists the attributes for preferences of the module QTSSFlowControlModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-11
Access
Data Type
Bool16
UInt32
UInt32
this attribute is 5.
loss_thin_tolerance By default, the value of
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
53
C H A P T E R
Concepts
Access
Data Type
UInt32
UInt32
this attribute is 6.
attribute is 3.
safe
UInt32
QTSSHomeDirectoryModule Preferences
Table 1-12 (page 54) lists the attributes for preferences of the module QTSSHomeDirectoryModule.
These preferences are maintained in the streamingserver.xml file.
Table 1-12
Access
Data Type
enabled Enable or disable this module. By default, the Readable, writable, not
preemptive safe
value of this attribute is false.
Bool16
Bool16
UInt32
have a value.
client connections greater than the value of this
attribute. By default, the value of this attribute is 0.
preemptive safe
max_bandwidth_kbps_per_home_directory Denies
UInt32
QTSSMP3StreamingModule Preferences
Table 1-13 (page 54) lists the attributes for preferences of the module QTSSMp3StreamingModule.
These preferences are maintained in the streamingserver.xml file.
Table 1-13
Access
Data Type
of this attribute is
/Library/QuickTimeStreaming/Logs.
54
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
has no value.
safe
safe
mp3_request_logging By default, the value of this Readable, writable, not preemptive Bool16
safe
attribute is true.
mp3_request_logfile_size By default, the value Readable, writable, not preemptive UInt32
safe
QTSSReflectorModule Preferences
Table 1-14 (page 55) lists the attributes for preferences of the module QTSSReflectorModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-14
Access
Data Type
Bool16
Bool16
Bool16
Bool16
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
55
C H A P T E R
Concepts
Access
Data Type
Bool16
char
preemptive safe
compatibility_adjust_sdp_media_bandwidth_percent Readable, writable, not
Bool16
Bool16
Bool16
Bool16
preemptive safe
Bool16
Bool16
preemptive safe
Bool16
Bool16
char
127.0.0.*.
preemptive safe
56
UInt32
preemptive safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Bool16
UInt32
C H A P T E R
Concepts
Access
Data Type
UInt16
UInt16
char
char
UInt32
UInt32
attribute is 65535.
minimum_statid_sdp_port By default, the value of this
attribute is 2000.
redirect_broadcast_keyword By default, this attribute
has no value.
redirect_broadcasts_dir By default, this attribute has
no value.
reflector_bucket_offset_delay_msc By default, the
preemptive safe
UInt32
preemptive safe
UInt32
Bool16
UInt32
preemptive safe
Bool16
QTSSRefMovieModule Preferences
Table 1-15 (page 58) lists the attributes for preferences of the module QTSSRefMovieModule, which
allows web developers to put RTSP URLs in web pages. These preferences are maintained in the
streamingserver.xml file.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
57
C H A P T E R
Concepts
Table 1-15
Access
Data
Type
refmovie_rtsp_port The port to use for RTSP request redirection. Readable, writable, UInt16
not preemptive
Technically, this is not a protocol redirect. It is a media or content
safe
level redirect. Works the same as if you had a text file on a Web
server called mymovie.mov that contained the RTSP URL with an
rtsptext QuickTime tag. The tag and file name extension would tell
the QuickTime client to RTSP stream the file. By default,the value
of this attribute is 554.
refmovie_xfer_enabled For QuickTime clients only, converts, for Readable, writable, Bool16
not preemptive
example, http://hostname/mymovie.mov to
rtsp://hostname:554/mymovie.mov. The server creates a text-based safe
ref movie as the HTTP response, which redirects the client to the
same movie on the server but as an RTSP request. This conversion
is useful for placing streaming movie references on a web server.
HTTP requests that do not specify a port go to port 80. However,
http://hostname:554/mymovie.mov also works. By default, the
value of this attribute is true.
QTSSRelayModule Preferences
Table 1-16 (page 58) lists the attributes for preferences of the module QTSSRelayModule. These
preferences are maintained in the streamingserver.xml file.
Table 1-16
Access
Data Type
qtssPrefsObjectType
An object of type qtssPrefsObjectType consists of attributes that describe the servers internal
preference storage system. A preference object (QTSS_PrefsObject) is an instance of this object type.
The attribute values for objects of this type are stored in the servers configuration file,
streamingserver.xml. For each server, there is a single instance of this object type.
In previous versions of the QTSS programming interface, module preferences were stored in this
object. Since version 4.0, module preferences have been stored in each modules QTSS_ModuleObject
object.
Table 1-17 (page 59) lists the attributes for objects of type qtssPrefsObjectType.
58
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Note: None of these attributes is preemptive safe, so they can must be read by calling QTSS_GetValue
or by locking the object, calling QTSS_GetValuePtr, and unlocking the object.
Table 1-17
Name in streamingserver.xml
Access
Dat
Typ
Readable,
Boo
writable,
not
preemptive
safe
alt_transport_src _ipaddr
Readable,
cha
writable,
not
preemptive
safe
always_thin_delay
Readable,
SIn
writable,
not
preemptive
safe
authentication _scheme
Readable,
cha
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
auto_restart
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Readable,
Boo
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
59
C H A P T E R
Concepts
Name in streamingserver.xml
Access
average_bandwidth _update
Readable,
UIn
writable,
not
preemptive
safe
qtssPrefsDefaultAuthorizationRealm
Readable,
Boo
writable,
not
preemptive
safe
default_authorization_realm
Readable,
cha
writable,
not
preemptive
safe
Boo
writable,
not
preemptive
safe
drop_all_packets _delay
Readable,
SIn
writable,
not
preemptive
safe
drop_all_video _delay
Readable,
SIn
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
do_report_http_connection_ip_address Readable,
Readable,
Boo
writable,
not
preemptive
safe
force_logs_close_on_write
60
Dat
Typ
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Dat
Typ
Name in streamingserver.xml
Access
qtssPrefsEnableMonitorStatsFile If set to
true, the server writes server statistics to the
enable_monitor _stats_file
Readable,
Boo
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
qtssPrefsPacketHeaderPrintfOptions attribute
RTSP_debug_printfs
Readable,
Boo
writable,
not
preemptive
safe
RTSP_error_message
Readable,
Boo
writable,
not
preemptive
safe
large_window_size
Readable,
UIn
writable,
not
preemptive
safe
max_send_ahead_time
Readable,
UIn
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
61
C H A P T E R
Concepts
Name in streamingserver.xml
Access
maximum_bandwidth
Readable,
SIn
writable,
not
preemptive
safe
maximum_connections
Readable,
SIn
writable,
not
preemptive
safe
Readable,
Flo
writable,
not
preemptive
safe
medium_window_size
Readable,
UIn
writable,
not
preemptive
safe
min_tcp_buffer_size
Readable,
UIn
writable,
not
preemptive
safe
module_folder
Readable,
cha
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
max_tcp_buffer_size
62
Dat
Typ
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Dat
Typ
Name in streamingserver.xml
Access
movie_folder
Readable,
cha
writable,
not
preemptive
safe
qtssPrefsMonitorStatsFileIntervalSec
monitor_stats_file_interval_seconds
Readable,
UIn
writable,
not
preemptive
safe
overbuffer_rate
Readable,
Flo
writable,
not
preemptive
safe
packet_header _printf_options
Readable,
cha
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Readable,
cha
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
63
C H A P T E R
Concepts
Name in streamingserver.xml
reliable_udp _printfs
Readable,
Boo
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
rtcp_rcv_buf_size
Readable,
UIn
writable,
not
preemptive
safe
64
Readable,
Boo
writable,
not
preemptive
safe
rtcp_poll_interval
Readable,
Boo
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
qtssPrefsRTCPPollIntervalInMsec A
Dat
Typ
reliable_udp_dirs
Access
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Dat
Typ
Name in streamingserver.xml
Access
rtp_timeout
Readable,
UIn
writable,
not
preemptive
safe
rtsp_port
Readable,
UIn
writable,
not
preemptive
safe
rtsp_timeout
Readable,
UIn
writable,
not
preemptive
safe
run_group_name
Readable,
cha
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
run_user_name
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Readable,
UIn
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
65
C H A P T E R
Concepts
Name in streamingserver.xml
small_window_size
Readable,
UIn
writable,
not
preemptive
safe
append_source_addr_in_transport
Readable,
Boo
writable,
not
preemptive
safe
66
Readable,
UIn
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
Dat
Typ
send_interval
Access
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Readable,
UIn
writable,
not
preemptive
safe
Readable,
SIn
writable,
not
preemptive
safe
Readable,
SIn
writable,
not
preemptive
safe
C H A P T E R
Concepts
Name in streamingserver.xml
thick_all_the_way _delay
total_bytes_update
window_size _threshold
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Access
Dat
Typ
Readable,
Flo
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
Readable,
SIn
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
67
C H A P T E R
Concepts
Dat
Typ
Name in streamingserver.xml
Access
disable_thinning
Readable,
Boo
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
error_logfile_dir
error_log_name
error_logfile _interval
68
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Readable,
cha
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
Readable,
cha
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
Readable,
UIn
writable,
not
preemptive
safe
C H A P T E R
Concepts
Name in streamingserver.xml
Access
Readable,
UIn
writable,
not
preemptive
safe
Readable,
Boo
writable,
not
preemptive
safe
screen_logging
qtssRTPStreamObjectType
An object of type qtssRTPStreamObjectType consists of attributes that describe a particular RTP
stream whether its an audio, video, or text stream. An RTP stream object (QTSS_RTPStreamObject)
is an instance of this object type and is created by calling QTSS_AddRTPStream. An RTP stream object
must be associated with a single client session object (QTSS_ClientSessionObject). A client session
object may be associated with any number of RTP stream objects. These attributes are valid for all
roles that receive a QTSS_RTPStreamObject in the structure the server passes to them.
Table 1-18 (page 69) lists the attributes for objects of type qtssRTPStreamObjectType.
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-18
Access
Data Type
Readable, preemptive
clients buffer. The server sets this attribute to safe
three seconds, but the module is responsible
for determining the buffer size and setting this
attribute accordingly.
Float32
Readable, writable,
number of the first packet after the last PLAY preemptive safe
request was issued. If known, this attribute
must be set by a module before calling
QTSS_Play. The server uses this attribute to
generate a proper RTSP PLAY response.
SInt16
qtssRTPStrFirstSeqNumber Sequence
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Dat
Typ
69
C H A P T E R
Concepts
Access
Data Type
SInt32
preemptive safe
of the first RTP packet generated for this
stream after the last PLAY request was issued.
If known, this attribute must be set by a
module before calling QTSS_Play. The server
uses this attribute to generate a proper RTSP
PLAY response.
qtssRTPStrNetworkMode Network mode for
Readable, preemptive
safe
UInt32
qtssRTPNetworkModeDefault,
qtssRTPNetworkModeMulticast, and
qtssNetworkModeUnicast.
qtssRTPStrPayloadName Name of the media Readable, writable,
char
QTSS_RTPPayloadType
preemptive safe
media for this stream. The value of this
attribute is qtssUnknownPayloadType unless
a module sets it to qtssVideoPayloadType or
qtssAudioPayloadType.
qtssRTPStrTrackID Unique ID that identifies Readable, writable,
UInt32
preemptive safe
SInt32
preemptive safe
Readable, preemptive
(SSRC) generated by the server. The SSRC is safe
guaranteed to be unique among all streams in
the session. The server includes the SSRC in
all RTCP Sender Reports that the server
generates.
qtssRTPStrSSRC Synchronization source
UInt32
The values of the following attributes come from the most recent RTCP packet received on a stream.
If a field in the most recent RTCP packet is blank, the server sets the value of the corresponding
attribute to zero.
qtssRTPStrAudioDryCount Number of times Readable, preemptive
safe
qtssRTPStrAvgBugDelayInMsec Average
Readable, preemptive
safe
UInt16
Readable, preemptive
safe
UInt16
70
UInt16
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
UInt16
safe
Data Type
UInt16
safe
Readable, preemptive
fraction of packets that have been lost for this safe
stream.
UInt32
UInt16
qtssRTPStrFractionLostPackets The
safe
UInt16
safe
Readable, preemptive
safe
UInt16
Bool16
UInt32
Readable, preemptive
safe
UInt32
UInt32
stream.
qtssRTPStrNumEyes Number of clients
safe
UInt32
safe
qtssRTPStrPercentPacketsLost Fixed
Readable, preemptive
safe
UInt16
Readable, preemptive
safe
UInt32
Readable, preemptive
used for sending RTP or RTCP packets to the safe
client. Use QTSS_WriteFlags to specify
whether each packet is an RTP or RTCP packet.
QTSS_StreamRef
Readable, preemptive
number of packets that have been lost for this safe
stream.
UInt32
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
71
C H A P T E R
Concepts
Access
Data Type
Readable, preemptive
safe
UInt32
UInt16
safe
Readable, preemptive
safe
UInt16
Readable, preemptive
safe
QTSS_RTPTransportType
lost.
qtssRTPStrTransportType The transport
type.
qtssRTSPHeaderObjectType
An object of type qtssRTSPHeaderObjectType consists of attributes containing all of the RTSP request
headers associated with an individual RTSP request. An RTSP header object (QTSS_RTSPHeaderObject)
is an instance of this object type.
The names of the attributes are the names of the RTSP headers associated with that RTSP request.
For example, the following RTSP request has a Session header and a User-agent header:
DESCRIBE /foo.mov RTSP/1.0
Session: 20fj02ijf
User-agent: QTS/4.0.3
In this case, the value of the Session attribute is 20fj02ijf and the value of the User-agent attribute
is QTS/4.0.3. Modules can get the value of a given header by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
qtssRTSPRequestObjectType
An object of type qtssRTSPRequestObjectType consists of attributes that describe a particular RTSP
request. An RTSP request object (QTSS_RTSPRequestObject) is an instance of this object type and
exists from the time the server receives a complete RTSP request from a client until the response is
sent and the server moves on to the next request. An RTSP request object must be associated with a
single RTSP session object (QTSS_RTSPSessionObject) for a given request made over a given
connection.
With the exception of the RTSP Filter role, the value of each attribute is available in all roles that
receive an object of type QTSS_RTSPRequestObject. When the RTSP Filter role receives an object of
type QTSS_RTSPRequestObject, the only attribute that has a value is the qtssRTSPReqFullRequest
attribute.
Each text name is identical to its enumerated type name.
Table 1-19 (page 73) lists the attributes for objects of type qtssRTSPRequestObjectType.
72
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-19
Access
Data Type
with rtsp://.
safe
qtssRTSPReqFilePathTrunc Same as
qtssRTSPReqFilePath, but without the last
this request.
safe
qtssRTPNetworkModeDefault,
qtssRTPNetworkModeMulticast, and
qtssRTPNetworkModeUnicast.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
73
C H A P T E R
Concepts
Access
Data Type
Bool16
Readable, writable,
sent back to the client if the response was an error. preemptive safe
A module sending an RTSP error to the client
should set this attribute to be a text message that
describes why the error occurred. It is also useful
to write this message to a log file. Once the RTSP
response has been sent, this attribute contains the
response message.
char
char
request. The default value for this attribute is the preemptive safe
server's media folder path. Modules can set this
attribute from the RTSP Route role.
qtssRTSPReqSkipAuthorization Set by a module Readable, writable,
Bool16
preemptive safe
safe
QTSS_RTSPStatusCode
74
safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
Readable, writable,
preemptive safe
for the client to display in the following string:
Please enter password for realm at server-name.
The default value of this attribute is Streaming
Server.
char
qtssRTSPSessionObjectType
An object of type qtssRTSPSessionObjectType consists of attributes associated with an RTSP
client-server connection. An RTSP session object (QTSS_RTSPSessionObject) is an instance of this
object type and exists as long as the RTSP client is connected to the server. These attributes are valid
for all roles that receive a QTSS_RTSPSessionObject in the structure the server passes to them.
Table 1-20 (page 75) lists the attributes for objects of type qtssRTSPSessionObjectType.
Note: All of these attributes are preemptive safe, so they can be read by calling QTSS_GetValue,
QTSS_GetValueAsString, or QTSS_GetValuePtr.
Table 1-20
Access
Data Type
Readable, preemptive
safe
for the RTCP connection to the client. This
attribute should primarily be used to wait for
flow-controlled EV_WR event when responding
to a client.
QTSS_EventContextRef
UInt32
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
75
C H A P T E R
Concepts
Access
Data Type
UInt32
safe
char
connection.
qtssRTSPSesRemoteAddr IP address of the
client.
qtssRTSPSesRemoteAddrStr IP address of
Readable, preemptive
safe
char
Readable, preemptive
safe
UInt16
Readable, preemptive
safe
UInt32
Readable, preemptive
safe
char
UInt16
safe
safe
Readable, preemptive
safe
QTSS_RTSPSessionStream
QTSS_RTSPSessionType
short lived.
qtssServerObjectType
An object of type qtssServerObjectType consists of attributes that contain global server information,
such as server statistics. A server object (QTSS_ServerObject is an instance of this object type.There
is a single instance of this object type for each server. These attributes are valid for all roles that receive
a QTSS_ServerObject in the structure the server passes to them.
Table 1-21 (page 77) lists the attributes for objects of type qtssServerObjectType.
76
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Note: Some of these attributes are not preemptive safe, as noted in Table 1-21 (page 77).
Table 1-21
Access
Data Type
Readable, writable,
bandwidth in bits per second that the server preemptive safe
is currently sending.
UInt32
UInt32
UInt32
Readable, writable,
preemptive safe
UInt32
Readable, writable,
preemptive safe
UInt32
Readable, not
preemptive safe
UInt32
Readable, not
bandwidth being output by the server in bits preemptive safe
per second.
UInt32
Readable, not
preemptive safe
UInt32
UInt32
preemptive safe
UInt32
preemptive safe
Readable, not
preemptive safe
UInt64
Readable, not
preemptive safe
UInt32
preemptive safe
qtssRTSPCurrentSessionCount The
Readable, not
preemptive safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
UInt64
UInt32
77
C H A P T E R
Concepts
Access
Data Type
qtssRTSPHTTPCurrentSessionCount The
Readable, not
preemptive safe
UInt32
qtssSvrClientSessions An object
Read
QTSS_Object
Float32
preemptive safe
Readable, not
servers current time in milliseconds. Getting preemptive safe
the value of this attribute is equivalent to
calling QTSS_Milliseconds.
QTSS_TimeVal
char
qtssSvrCurrentTimeMilliseconds The
safe
78
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
Bool16
QTSS_Object
safe
Readable, not
containing all the ports the server is listening preemptive safe
on.
char
char
safe
char
safe
qtssSvrServerVersion The version of the Readable, preemptive
server.
char
safe
QTSS_TimeVal
safe
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
79
C H A P T E R
Concepts
qtssTextMessageObjectType
An object of type qtssTextMessageObjectType consists of attributes whose values are intended for
display to the user or that are returned to the client. A text message object (QTSS_TextMessageObject)
is an instance of this object type. To make localization easier, the attribute values are text strings.
Table 1-22 (page 80) lists the attributes for objects of type qtssTextMessageObjectType.
Table 1-22
Access
Data Type
qtssListenPortAccessDenied
char
qtssListenPortError
char
qtssListenPortInUse
char
char
char
qtssMsgBadFormat The server could not parse the request. Read only, preemptive safe
char
char
char
qtssMsgCannotCreatePIDFile The server could not create Read only, preemptive safe
the process ID file. See the qtssPrefsPIDFile attribute
of the qtssPrefsObjectType described in Table
char
module.
qtssMsgBadRTSMethod Request specified an invalid RTS
method.
char
char
char
qtssMsgCantWriteFile
char
char
for multicast.
80
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Access
Data Type
char
char
char
qtssMsgInitFailed The server could not initialize itself. Read only, preemptive safe
char
char
char
qtssMsgNoMessage No message.
char
char
char
module folder.
the server does not have.
Read only, preemptive safe
char
qtssMsgNoRTSPVersion Request did not specify an RTSP Read only, preemptive safe
char
char
char
qtssMsgNoPortsSucceeded
char
ID.
qtssMsgNotConfiguredForIP The server is not configured Read only, preemptive safe
char
for IP.
qtssMsgNoURLInRequest Request did not contain a URL. Read only, preemptive safe
char
char
char
char
connections.
qtssMsgRegFailed A module failed to register.
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
81
C H A P T E R
Concepts
Access
Data Type
char
char
RTCP port number that is not bigger than the RTP port
number by 1.
Read only, preemptive safe
char
qtssMsgSockBufSizesTooLarge
char
char
char
char
char
qtssMsgURLTooLong Request contains a URL that is longer Read only, preemptive safe
char
properly formatted.
than 256 bytes.
qtssServerPrefMissing A required server preference is Read only, preemptive safe
char
char
qtssUserProfileObjectType
An object of type qtssUserProfileObjectType consists of attributes whose values describe a users
profile.
Table 1-23 (page 82) lists the attributes for objects of type qtssUserProfileObjectType.
Table 1-23
Access
Data Type
char
char
82
QTSS Objects
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
char
C H A P T E R
Concepts
Access
Data Type
char
QTSS Streams
The QTSS programming interface provides QTSS stream references as a generalized stream abstraction.
Streams can be used for reading and writing data to many types of I/O sources, including, but not
limited to files, the error log, and sockets and for communicating with the client via RTSP or RTP. In
all RTSP roles, for example, modules receive an object of type QTSS_RTSPRequestObject that has a
qtssRTSPReqStreamRef attribute. The value of this attribute is of type QTSS_StreamRef, and it can
be used for sending RTSP response data to the client.
Unless otherwise noted, all streams are asynchronous. When using the asynchronous QTSS file system
callbacks, modules should be prepared to receive the QTSS_WouldBlock result code, subject to the
restrictions and rules of each stream type described in this section. The QTSS_WouldBlock error is
returned from a stream callback when completing the requested operation would require the current
thread to block. For instance, QTSS_Write on a socket will return QTSS_WouldBlock if the socket is
currently subject to flow control. For information on threading and asynchronous I/O, see the section
Runtime Environment for QTSS Modules (page 30).
When a module receives the QTSS_WouldBlock result code, modules should call the
QTSS_RequestEvent callback routine to request a notification from the server when the specified
stream becomes available for I/O. After calling QTSS_RequestEvent, the module should return control
immediately to the server. The module will be re-invoked in the same role in the exact same state
when the specified stream is available for I/O.
All stream references are of type QTSS_StreamRef. The QTSS programming interface uses following
stream types:
QTSS_ErrorLogStream
Used for writing binary data to the servers error log. There is a single instance of this stream
type, which is passed to each module in the Initialize role. When data is written to this stream,
modules that have registered for the Error Log role are invoked. For information about this
role, see the section Error Log Role (page 35). All operations on this stream type are
synchronous.
QTSS_FileStream
Represents a file and is obtained by making the QTSS_OpenFileStream callback. If the file
stream is opened with the qtssFileStreamAsync flag, callers should expect to receive a result
code of QTSS_WouldBlock when they call QTSS_Read, QTSS_Write, and QTSS_WriteV.
QTSS_RTSPSessionStream
Used for reading data (QTSS_Read) from an RTSP client and writing data (QTSS_Write or
QTSS_WriteV) to an RTSP client. The server may encounter flow control conditions, so modules
should be prepared to handle QTSS_WouldBlock result codes when reading from or writing
to this stream type. Calling QTSS_Read means that you are reading the request body sent by
QTSS Streams
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
83
C H A P T E R
Concepts
the client to the server. This stream reference is an attribute of the object
QTSS_RTSPSessionObject.
QTSS_RTSPRequestStream
Used for reading data (QTSS_Read) from an RTSP client and writing data (QTSS_Write or
QTSS_WriteV) to an RTSP client. This stream is identical to the QTSS_RTSPSessionStream
stream except that data written to streams of this type is buffered in memory until a full RTSP
response is constructed. Because the data is buffered internally, modules do not receive
QTSS_WouldBlock errors when writing to streams of this type. Calling QTSS_Readon this
type of stream means that you are reading the request body sent by the client to the server.
Modules that call QTSS_Read to read this type of stream should be prepared to handle
a result code of QTSS_WouldBlock. This stream reference is an attribute of the object
QTSS_RTSPRequestObject.
QTSS_RTPStreamStream
Used for writing data to an RTP client. When writing to a stream of this type, a single write
call corresponds to a single, complete RTP packet, including headers. Currently, it is not possible
to use the QTSS_RequestEvent callback to receive events for this stream, so if QTSS_Write or
QTSS_WriteV returns QTSS_WouldBlock, modules must poll periodically for the blocking
condition to be lifted. This stream reference is an attribute of the object QTSS_RTPStreamObject.
QTSS_SocketStream
Represents a socket. This stream type allows modules to use the QTSS stream event mechanism
(QTSS_RequestEvent) for raw socket I/O. (In fact, the QTSS_RequestEvent callback is the only
stream callback available for this type of stream.) Modules should read sockets asynchronously
and should use the operating systems socket function to read from and write to sockets. When
those routines reach a blocking condition, the module can call QTSS_RequestEvent to be
notified when the blocking condition has cleared.
Table 1-24 (page 84) uses an X to summarize the I/O-related callback routines that are appropriate
for each type of stream.
Table 1-24
Stream Type
File Stream
Error Log
X
X
Socket Stream
RTSP Session Stream
84
X
X
RTP Stream
QTSS Streams
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
QTSS Services
QTSS services are services the modules can access. The service may be a built-in service provided by
the server or an added service provided by another module. An example of a service would be a
logging module that allows other modules to write messages to the error log.
Modules use the callback routines described in the section Service Callback Routines (page 166) to
register and invoke services. Modules add and find services in a way that is similar to the way in
which they add and find attributes of an object.
Every service has a name. To invoke a service, the calling module must know the name of the service
and resolve that name into an ID.
Each service has its own specific parameter block format. Modules that export services should carefully
document the services they export. Modules that call services should fail gracefully if the service isnt
available or returns an error.
A module that implements a service calls QTSS_AddService in its Register role to add the service to
the servers internal database of services, as shown in the following code:
void MyAddService()
{
QTSS_Error theErr = QTSS_AddService("MyService", &MyServiceFunction);
}
The MyServiceFunction corresponds to the name of a function that must be implemented in the
same module. Here is a stub implementation of the MyServiceFunction:
QTSS_Error MyServiceFunction(MyServiceArgs* inArgs)
{
// Each service function must take a single void* argument
// Implement the service here.
// Return a QTSS_Error.
}
To use a service, a module must get the services ID by calling QTSS_IDForService and providing
the name of the service as a parameter. With the services ID, the module calls QTSS_DoService to
cause the service to run, as shown in Listing 1-1 (page 85).
Listing 1-1
Starting a service
void MyInvokeService()
{
// Service functions take a single void* parameter that corresponds
// to a parameter block specific to the service.
MyServiceParamBlock theParamBlock;
// Initialize service-specific parameters in the parameter block.
theParamBlock.myArgument = xxx;
QTSS_ServiceID theServiceID = qtssIllegalServiceID;
// Get the service ID by providing the name of the service.
QTSS_Error theErr = QTSS_IDForService(MyService, &theServiceID);
if (theErr != QTSS_NoErr)
return; // The service isnt available.
QTSS Services
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
85
C H A P T E R
Concepts
Built-in Services
The QuickTime Streaming Server provides built-in services that modules may invoke using the service
routines. In this version of the QTSS programming interface, there is one built-in service:
#define QTSS_REREAD_PREFS_SERVICE "RereadPreferences"
Invoking the Reread Preferences service causes the server to reread its preferences and invoke each
module in the Reread Preferences role, if they have registered for that role.
To invoke a built-in service, retrieve the service ID of the service by calling QTSS_IDForService. Then
call QTSS_DoService to run the service.
Automatic Broadcasting
The Streaming Server can accept RTSP ANNOUNCE requests from QuickTime broadcasters. Support
for ANNOUNCE requests and the ability of the server to act as an RTSP client allow the server to
initiate new relay sessions. This section describes the two ways in which an automatic broadcast can
be initiated, how ANNOUNCE requests work with SDP, and how the qtaccess and qtusers files
control automatic broadcasting.
Pull then push. To initiate automatic broadcast, an RTSP client sends standard RTSP requests to
request a stream and the server then relays the stream to one or more other streaming servers.
This scenario is described in the section Pull Then Push (page 86).
Listen then push. In this scenario, an automatic broadcast is initiated when the streaming server
receives an ANNOUNCE request. This scenario is described in the section Listen Then
Push (page 87).
86
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Figure 1-7
1. DESCRIBE/SETUP/PLAY
Streaming
Server
Streaming
Server B
Streaming
Server
Using Figure 2-7 (page 87) as a reference, the steps for the pull-then-push scenario are as follows:
1.
Streaming Server A (the relay client) sends standard RTSP client DESCRIBE/SETUP/PLAY
requests to a remote server, Streaming Server B.
2.
The relay client (Streaming Server A) that requested the stream will begin receiving it and then
send an ANNOUNCE to all of the destinations listed in the relay configuration for that particular
incoming stream.
Broadcaster
Streaming
Server A
3. ANNOUNCE
Streaming
Server
Streaming
Server
Using Figure 2-8 (page 87) as a reference, the steps for the listen -then-push scenario are as follows:
If the stream should be relayed, the streaming server will send standard RTSP client
DESCRIBE/SETUP/PLAY request to itself.
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
87
C H A P T E R
Concepts
The relay client (Streaming Server A) that requested the stream will begin receiving it and then
send an ANNOUCE to all of the destinations listed in its relay configuration for that particular
incoming stream.
The a=x-urlmap tag is required to support sharing streams between broadcasts (where one stream
comes from one broadcaster and another stream comes from another broadcaster). The a=x-urlmap
tag should appear in the SDP that references the source SDP. Here is an example:
a=x-urlmap: someotherbroadcastURL/TrackID=1
valid-user Specifies that the user can have access to the requested movie if the client provides
a name and password that match an entry in the qtusers file. The tag is written as
require valid-user.
any-user
88
Specifies that any user can have access to the requested movie, with no requirement
that the user be defined in the qtusers file or that the client provide a name and
password that is checked. The tag is written as require any-user.
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
By default, the qtaccess file allows read access for all directives in the file. To allow announced
broadcasts, the qtaccess file must contain a Limit directive that allows writing.
The purpose of the Limit directive is to restrict the effect of access controls to RTSP readers or writers.
The following example limits the require access control so that only users defined in the qtusers
file can RTSP PLAY a broadcast to the server. All other normal client PLAY requests are available to
any user:
<Limit WRITE>
require valid-user
</Limit>
Note: The termination of the Limit directive (</Limit>) must be placed on its own line.
The following example allows movie viewing by any user in the qtusers file that is in the
movie_watchers group and the user john. Broadcasters must be in the movie_broadcasters group
to broadcast to this directory or its protected branches.
<Limit READ>
require group movie_watchers
require user john
</Limit>
<Limit WRITE>
require group movie_broadcasters
</Limit>
The following example allows movie viewing and broadcasting by any user in the qtusers file that
is in the movie_watchers_and_broadcasters group:
<Limit READ WRITE>
require group movie_watchers_and_broadcasters
</Limit>
Broadcaster-to-Server Example
This section shows a typical exchange between a client and a server in order to initiate an announced
broadcast. The following example shows a UDP multicast. Announced broadcasts can also set up
requests with using unicast RTP/AVP/UDP streams as well as RTP/AVP/TCP interleaved streams.
For more information, see RFC 2326.
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
89
C H A P T E R
Concepts
Client to server:
ANNOUNCE rtsp://server.example.com/meeting RTSP/1.0
CSeq: 90
Content-Type: application/sdp
Content-Length: 121
v=0
o=camera1 3080117314 3080118787 IN IP4 195.27.192.36
s=IETF Meeting, Munich - 1
i=The thirty-ninth IETF meeting will be held in Munich, Germany
u=http://www.ietf.org/meetings/Munich.html
e=IETF Channel 1 <ietf39-mbone@uni-koeln.de>
p=IETF Channel 1 +49-172-2312 451
c=IN IP4 224.0.1.11/127
t=3080271600 3080703600
a=tool:sdr v2.4a6
a=type:test
m=audio 0 RTP/AVP 5
a=control:trackID=1
c=IN IP4 224.0.1.11/127
a=ptime:40
m=video 0 RTP/AVP 31
a=control:trackID=2
c=IN IP4 224.0.1.12/127
Server to client:
RTSP/1.0 200 OK
CSeq: 90
Client to server:
SETUP rtsp://server.example.com/meeting/trackID=1 RTSP/1.0
CSeq: 91
Transport: RTP/AVP;multicast;destination=224.0.1.11;
client_port=21010-21011;mode=record;ttl=127
Server to client:
RTSP/1.0 200 OK
CSeq: 91
Session: 50887676
Transport: RTP/AVP;multicast;destination=224.0.1.11;
client_port=21010-21011;serverport=6000-6001;mode=receive;ttl=127
Client to server:
SETUP rtsp://server.example.com/meeting/trackID=2 RTSP/1.0
CSeq: 92
Session: 50887676
Transport: RTP/AVP;multicast;destination=224.0.1.12;
client_port =61010-61011;mode=record;ttl=127
Server to client:
RTSP/1.0 200 OK
CSeq: 92
Transport: RTP/AVP;multicast;destination=224.0.1.12;
client_port =61010-61011;serverport=6002-6003;mode=record;ttl=127
90
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Client to server:
RECORD rtsp://server.example.com/meeting RTSP/1.0
CSeq: 93
Session: 50887676
Server to client:
RTSP/1.0 200 OK
CSeq: 93
RTSP SETUP to send a Transport header setting mode=record; the direction of the stream is
implicitly from the perspective of the server
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
// 127
91
C H A P T E R
Concepts
\r\n
c=IN IP4
127.0.0.1\ra=x-qt-text-nam:test\ra=x-qt-text-cpy:apple\
ra=x-qt-text-aut:john\
ra=x-qt-text-inf:none\
ra=mpeg4-iod:"data:application/
mpeg4-iod;base64,AoF/
AE8BAQEBAQOBEgABQHRkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9kLWF1O2Jhc2U2NCxBVGdC
R3dVZkF4Y0F5U1FBWlFRTklCRUFGM0FBQVBvQUFBRERVQVlCQkFFWkFwOERGUUJsQlFRTlFC
VUFCOUFBQUQ2QUFBQStnQVlCQXc9PQQNAQUAAMgAAAAAAAAAAAYJAQAAAAAAAAAAA2EAAkA+
ZGF0YTphcHBsaWNhdGlvbi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTZ1RBcUJYSmhCSWhR
UlFVL0FBPT0EEgINAAAUAAAAAAAAAAAFAwAAQAYJAQAAAAAAAAAA"\ra=ismacompliance:1,1.0,1\rm=audio 0 RTP/AVP 96\ra=rtpmap:96
X-QT/8000/1\ra=control:trackid=1\rm=video 0 RTP/AVP 97\ra=rtpmap:97
MP4V-ES\ra=fmtp:97
profile-level-id=1;config=000001B0F3000001B50EE040C0CF0000010000000120008440FA285020F0
A31F\ra=mpeg4-esid:201\ra=cliprect:0,0,240,320\ra=control:trackid=2\r
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 1\r\n
\r\n
Client to server:
// The broadcaster is trying to determine if RECORD is supported. QTSS 4.0 used
an Apple
// method of RECEIVE instead of the RECORD.
OPTIONS rtsp:
CSeq: 2\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 2\r\n
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, ANNOUNCE, SET_PARAMETER,
RECORD\r\n
\r\n
Client to server:
// Here is the first setup with the transport defined from the client to the
// server. The URL is the same as when a client performs a setup requesting
// a stream. QTSS does not allow a SETUP on a stream that is already set up
// and will return an error. This can happen in two ways.
// 1) A broadcast software error that does not change the URL.
// 2) A broadcast dies without performing a teardown. In this case, the
// broadcast session has to timeout and die before another setup can occur.
// The server uses a short timeout of 20 seconds for broadcast sessions. The
// timeout is refreshed by any packet received from the broadcaster.
SETUP rtsp:
CSeq: 3\r\n
92
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
// 127
C H A P T E R
Concepts
Transport: RTP/AVP/TCP;unicast;mode=record;interleaved=0-1\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
Accept-Language: en-US\r\n
\r\n
Server to client:
// The server responds with the interleaved values. If the values conflict,
// the client will change them so each stream has a unique set of
// interleaved IDs.
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 3\r\n
Cache-Control: no-cache\r\n
Session: 6664885458621367225\r\n
Date: Thu, 13 Feb 2003 21:34:27 GMT\r\n
Expires: Thu, 13 Feb 2003 21:34:27 GMT\r\n
Transport: RTP/AVP/TCP;unicast;mode=record;interleaved=0-1\r\n
\r\n
Client to server:
SETUP rtsp:
CSeq: 4\r\n
Transport: RTP/AVP/TCP;unicast;mode=record;interleaved=2-3\r\n
Session: 6664885458621367225\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
Accept-Language: en-US\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 4\r\n
Session: 6664885458621367225\r\n
Cache-Control: no-cache\r\n
Date: Thu, 13 Feb 2003 21:34:27 GMT\r\n
Expires: Thu, 13 Feb 2003 21:34:27 GMT\r\n
Transport: RTP/AVP/TCP;unicast;mode=record;interleaved=2-3\r\n
\r\n
Client to server:
// This is the equivalent to a client PLAY request. The broadcaster is now
// starting the streams.
RECORD rtsp:
CSeq: 5\r\n
Session: 6664885458621367225\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
// 127
Server to client:
// RTCPs will be sent back on the channels to show the number of watching
// clients.
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
93
C H A P T E R
Concepts
Client to server:
PAUSE rtsp:
CSeq: 6\r\n
Session: 6664885458621367225\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 6\r\n
Session: 6664885458621367225\r\n
\r\n
Client to server:
// A TEARDOWN stops the broadcast streams. It does not stop the clients or
// their streams. By default, QTSS allows a restarted or different broadcaster
// to send to the same URL and the clients will receive the new streams. This
// can be both good and bad since the broadcaster can change the stream media
// type on the clients. The streamingserver.xml file provides an attribute
// that allows the server to force clients to disconnect if the broadcaster
// disconnects. The broadcast receiver is recommended to have a way for an
// administrator or the broadcaster to tear down sessions that have failed.
// The server adds a 30 second timeout between SSRC values to prevent someone
// from pirating a stream. As long as a stream is playing with the initial
// SSRC, another stream arriving on the same ports will not be reflected to
// clients. Attempts to pirate a steam usually occur by accident when users
// manually set their SDP ports.
TEARDOWN rtsp:
// 127
CSeq: 7\r\n
Session: 6664885458621367225\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
Server to client:
// The server removes the SDP file from the movies directory on teardown or
// broadcaster timeout.
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 7\r\n
Session: 6664885458621367225\r\n
Connection: Close\r\n
\r\n
94
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 1\r\n
\r\n
Client to server:
OPTIONS rtsp:
CSeq: 2\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 2\r\n
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, ANNOUNCE, SET_PARAMETER,
RECORD\r\n
\r\n
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
95
C H A P T E R
Concepts
Client to server:
SETUP rtsp:
CSeq: 3\r\n
Transport: RTP/AVP;unicast;client_port=6974-6975;mode=record\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
Accept-Language: en-US\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 3\r\n
Cache-Control: no-cache\r\n
Session: 1549167172936112945\r\n
Date: Thu, 13 Feb 2003 21:59:22 GMT\r\n
Expires: Thu, 13 Feb 2003 21:59:22 GMT\r\n
Transport:
RTP/AVP;unicast;client_port=6974-6975;mode=record;source=127.0.0.1;
server_port=6976-6977\r\n
\r\n
Client to server:
SETUP rtsp:
CSeq: 4\r\n
Transport: RTP/AVP;unicast;client_port=6972-6973;mode=record\r\n
Session: 1549167172936112945\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
Accept-Language: en-US\r\n
\r\n
// 127
Server to client:
RTSP/1.0 200 OK\r\n
Server: QTSS/4.1.3.x (Build/425; Platform/MacOSX; Release/Development;)\r\n
Cseq: 4\r\n
Session: 1549167172936112945\r\n
Cache-Control: no-cache\r\n
Date: Thu, 13 Feb 2003 21:59:22 GMT\r\n
Expires: Thu, 13 Feb 2003 21:59:22 GMT\r\n
Transport:
RTP/AVP;unicast;client_port=6972-6973;mode=record;source=127.0.0.1;
server_port=6978-6979\r\n
\r\n
Client to server:
RECORD rtsp:
CSeq: 5\r\n
Session: 1549167172936112945\r\n
User-Agent: QTS (qtver=6.1;cpu=PPC;os=Mac 10.2.3)\r\n
\r\n
Server to client:
RTSP/1.0 200 OK\r\n
96
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
// 127
C H A P T E R
Concepts
Server to client:
RTSP/1.0 200 OK
CSeq: 90
Client to server:
SETUP rtsp://server.example.com/meeting/audiotrack RTSP/1.0
CSeq: 91
Transport: RTP
AVP;multicast;destination=224.0.1.11;port=21010-21011;mode=record;ttl=127
Server to client:
RTSP/1.0 200 OK
CSeq: 91
Session: 50887676
Transport: RTP
AVP;multicast;destination=224.0.1.11;port=21010-21011;mode=record;ttl=127
Automatic Broadcasting
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
97
C H A P T E R
Concepts
Client to server:
SETUP rtsp://server.example.com/meeting/videotrack RTSP/1.0
CSeq: 92
Session: 50887676
Transport: RTP/
AVP;multicast;destination=224.0.1.12;port=61010-61011;mode=record;ttl=127
Server to client:
RTSP/1.0 200 OK
CSeq: 92
Transport: RTP
AVP;multicast;destination=224.0.1.12;port=61010-61011;mode=record;ttl=127
Client to server:
RECORD rtsp://server.example.com/meeting RTSP/1.0
CSeq: 93
Session: 50887676
Range: clock=19961110T1925-19961110T2015
Server to client:
RTSP/1.0 200 OK
CSeq: 93
Stream Caching
This version of QTSS includes RTSP and RTP features that make it as easy for a caching proxy server
to capture and manage a pristine copy of a media stream. Some of these features are elements of RTSP
that were not supported in previous versions of QTSS, and other features are additions to RTSP and
RTP. The features are
98
Speed RTSP header. This version of QTSS supports the speed header wherever possible. The speed
header allows a caching proxy server to request that a stream be delivered faster than real time
so that the caching proxy server can move the stream into the cache as quickly as possible. This
header is described in the section Speed RTSP Header (page 99).
x-Transport-Options RTSP header. This version of QTSS supports the non-standard RTSP header,
x-Transport-Options. Caching proxy servers can use this header to tell the streaming server
how late packets the streaming server can send packets and have them still be useful to the caching
proxy server. This header is described in the section x-Transport-Options Header (page 99).
RTP payload meta-information. This version of QTSS fully supports RTP payload meta-information
(an IETF draft), which includes information such as the packet transmission time, unique packet
number, and video frame type. Caching proxy servers can use this information to provide the
same quality of service to clients as the originating server. This header is described in the section
RTP Payload Meta-Information (page 100).
x-Packet-Range RTSP header. This version of QTSS supports the non-standard RTSP header,
x-Packet-Range. This header is similar to the Range RTSP header but allows the client to specify
a specific range of packets instead of a range of time. A caching proxy server can use the
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
x-Packet-Range header to tell the originating server to selectively retransmit only those packets
that the caching proxy server needs in order to fill in holes in its cached copy of the stream. This
header is described in the section x-Packet-Range RTSP Header (page 105).
The following sections describe each of these features.
x-Transport-Options Header
The optional x-Transport-Options RTSP header should be sent from a client (typically a caching
proxy server) to the server in an RTSP SETUP request and must echoed by the server. If the server
does not echo the x-Transport-Options header, the client must assume that the server does not
support this header. The server may modify the value of the x-Transport-Options header argument.
If the server modifies the value of the argument, the client must accept the modified value.
The body of this header contains one or more arguments delimited by the semicolon character. For
this version of QTSS, there is only one argument, the late-tolerance argument.
The value of the late-tolerance argument is a positive integer that represents the number of seconds
late that the server can send a media packet and still have it be useful to the client. The server should
use the value of the late-tolerance argument as a guide for making a best-effort attempt to deliver
all media data so that the delivered data is no older than the late-tolerance value.
Here is an example:
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
99
C H A P T E R
Concepts
x-Transport-Options: late-tolerance=30
If this example were for a video stream, the server would send all video frames that are less than 30
seconds old. The server would drop frames that are more than 30 seconds old because they are stale.
Caching proxy servers can use the x-Transport-Options header to prevent the media server from
dropping frames or lowering the stream bit rate in the event it falls behind in sending media data. If
the caching proxy server knows the duration of the media, it can prevent the server from dropping
any frames by setting the late-tolerance argument to the duration of the media, allowing the cache
to receive a complete copy of the media data.
For a live broadcast, a caching proxy server may want to do extra buffering to improve quality for
its clients. It could use the x-Transport-Options header to advertise the length of its buffer to the
server.
RTP Data
The server uses the RTP payload meta-information type to provide the following information to the
RTP client:
Transmission Time
The server sends the transmission time as a single four-octet unsigned integer representing the
recommended transmission time of the RTP packet in milliseconds.
The transmission time is always offset from the start of the media presentation. For example, if the
SDP response for a URL includes a range of 0-729.45 and the client makes a PLAY request with a
range of 100-729.45, the first RTP packet from the server should provide a transmission time value
100
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
of approximately 100,000. (It may not be exactly 100,000 because the server is free to find a frame
nearby the requested time.) If the SDP for a URL does not contain a range, the client can at least use
these values as relative offsets.
Frame Type
The server sends the frame type as a single 16-bit unsigned integer value for which several well-known
values representing different frame types are defined. The well-known values are as follows:
2 represents a b-frame
3 represents a p-frame
Note: The frame type is valid for video RTP streams only.
Packet Number
The server sends the packet number as a single 64-bit unsigned integer value. The value is the packet
number offset from the absolute start of the stream. For example, if the SDP response for a URL
includes a range of 0-729.45 and the client makes a PLAY request with a range of 0-729.45, the packet
number value of the first packet will be 0 and will increment by 1 for each subsequent packet. If there
are 1000 packets between in the first 60 seconds of a stream and a client makes a PLAY request of
60-729.45, the packet number of the first packet will be 1001 and will increment by 1 for each subsequent
packet.
Packet Position
The server sends the packet position as a single 64-bit unsigned integer value. The value is the byte
offset of this packet from the absolute start of the stream. For example, if the SDP response for a URL
includes a range of 0-729.45 and the client makes a PLAY request with a range of 100-729.45, the
packet position value of the first video RTP packet will be the total number of bytes of the video RTP
packets between 0 and 100. Only the RTP packet payload bytes are used to compute each packet
position value.
The server cannot provide the packet position for live or dynamic media. In general, if the media SDP
has a range attribute, the server can provide the packet position.
Media Data
The server sends media data for the underlying RTP protocol.
Sequence Number
The server sends the RTP sequence number as a two-octet value. The sequence number is useful for
mapping RTP meta-information to the underlying payload data that they refer to, if that data is being
sent out-of-band.
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
101
C H A P T E R
Concepts
Standard Format
The RTP payload meta-information returned by the server consists of a series of fields. Each field
consists of a header and data. When returned in standard format, the first bit of the header is zero to
indicate that the field is in standard format (that is, not compressed).
The first bit is followed by the 15-bit Name subfield. The Name subfield contains two ASCII
alphanumeric characters that represent one of the RTP data types listed in the section RTP
Data (page 100). The first character is seven bits long, so the value of the Name subfield must consist
of seven-bit ASCII characters.
Table 2-26 (page 102) lists the Name subfield values for each of the RTP data types.
Table 1-26
Transmission time tt
Frame type
ft
Packet number
pn
Packet position
pp
Media
md
Sequence number
sn
The Name subfield is followed by a two-octet Length subfield that contains the full length of the Data
subfield.
Figure 2-9 (page 102) shows the format of the Name subfield in standard format.
Figure 1-9
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
0
length
Name
data
length
Name
data
Figure 2-10 (page 103) shows the format of the RTP data in standard format.
102
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Figure 1-10
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Transmit time data
tt
(transmit time)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Frame type data
ft
(frame type)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Packet number data
pn
(high order packet number)
(low order packet number)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Packet position data
pp
(high order packet number)
(low order packet number)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Media data
md
(field length)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Sequence number
sq
(sequence number)
Compressed Format
When the server provides a field of RTP meta-information in compressed format, the field consists
of a header and data. The first bit of the header is set to one to indicate that the rest of the header is
in compressed format.
The first bit is followed by a seven-bit ID subfield that identifies the type of data in the Data subfield.
The meaning of the ID subfield is assigned by the server, as described in the section x-RTP-Meta-Info
RTSP Header Negotiation (page 104).
The ID subfield is followed by the one-octet Length subfield that contains the full length of the Data
subfield that follows the Length subfield.
Figure 2-11 (page 104) shows the format of the ID subfield in compressed format.
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
103
C H A P T E R
Concepts
Figure 1-11
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1
ID
length
data
ID
length
data
ID
length
data
Figure 2-12 (page 104) shows an RTP payload meta-information packet when some fields are in
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1
length
ID
data
length
Name
data
ID
Compressed format
length
Standard format
data
Compressed format
Through the x-RTP-Meta-Info RTSP header, described in the section x-RTP-Meta-Info RTSP
Header Negotiation (page 104)
Through the SDP description of the data, described in the section Describing RTP-Meta-Info
Payload in SDP (page 105)
104
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
x-RTP-Meta-Info: to;bi;bo
The servers response lists the names of the RTP data that the server will provide for that RTP stream.
If the server supports the compressed format, the response may also contain ID mappings for some
or all of the names. The server may return a subset of the names if it doesnt support all of the requested
names, or if some requested names dont apply to the RTP stream specified by the SETUP request.
Here are two examples of a server response:
x-RTP-Meta-Info: to=0;bi;bo=1
x-RTP-Meta-Info: to;bi
In the first response, the server indicates that it will provide bi data in standard format. The server
will send to data in compressed format and use an ID of 0 to indicate fields that contain to data. The
server will send bo data in compressed format and use an ID of 1 to indicate fields that contain bo
data. Because IDs are represented by seven bits, an ID must be between 0 and 127.
In the second response, the server indicates that it will provide to and bi data in standard format.
Describing RTP-Meta-Info Payload in SDP
The originator of RTP-Meta-Info payload packets should describe the contents of the payload as part
of the SDP description of the media. RTP-Meta-Info descriptions consist of two additional a= headers.
The a=x-embedded-rtpmap header tells the client the payload type of the underlying RTP payload.
The a=x-RTP-Meta-Info header tells the client the RTP data types the server will provide. Here is
an example of an SDP description of the RTP-Meta-Info payload:
m=other 5084 RTP/AVP 96
a=rtpmap:96 x-RTP-Meta-Info
a=x-embedded-rtpmap:96 x-QT}
a=x-RTP-Meta-Info: standard;to;bi;bo
Stream Caching
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
105
C H A P T E R
Concepts
The stop packet number must be equal to or greater than the start packet number. Otherwise, the
server may return an error or may not send any media data after the PLAY response.
Reliable UDP
Reliable UDP is a set of quality of service enhancements, such as congestion control tuning
improvements, retransmit, and thinning server algorithms, that improve the ability to present a good
quality RTP stream to RTP clients even in the presence of packet loss and network congestion. Reliable
UDPs congestion control mechanisms allow streams to behave in a TCP-friendly fashion without
disturbing the real-time nature of the protocol.
To work well with TCP traffic on the Internet, Reliable UDP uses retransmission and congestion
control algorithms similar to the algorithms used by TCP. Additionally, these algorithms are time-tested
to utilize available bandwidth optimally.
Relibable UDP features include
Windowing and congestion control so the server does not exceed the currently available bandwidth
Whether a client uses Reliable UDP is determined by the content of the clients RTSP SETUP request.
Acknowledgment Packets
When using Reliable UDP, the server expects to receive an acknowledgment for each RTP packet it
sends. If the server does not receive an acknowledgment for a packet, it may retransmit the packet.
The client does not need to send an acknowledgment packet for each RTP packet it receives. Instead,
the client can coalesce acknowledgments for several packets and send them to the server in a single
packet.
The Reliable UDP acknowledgment packet format is a type of RTCP APP packet. After the standard
RTCP APP packet headers, the payload for an acknowledgment packet consists of an RTP sequence
number followed by a variable length bit mask. The sequence number identifies the first RTP packet
that the client is acknowledging. Each additional RTP packet being acknowledged is represented by
a bit set in the bitmask. The bit mask is an offset from the specified sequence number, where the high
order bit of the first byte in the mask is one greater than the sequence number, the second bit is two
greater, and so on. Bit masks must be sent in multiples of four octets. Setting a bit to 0 in the mask
simply means that the client does not wish to acknowledge this sequence number right now and does
not imply a negative acknowledgment.
Figure 2-13 (page 107) shows the format of the Reliable UDP acknowledgment packet.
106
Reliable UDP
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Concepts
Figure 1-13
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
V=2 P subtype
PT=APP=204
length
SSRC/CSRC
name (ASCII)='qtak'
SSRC/CSRC
reserved
seq num
mask...
RTSP Negotiation
Whether to use Reliable UDP is negotiated out of band in RTSP. If a client wants to use Reliable UDP,
it should include an x-Retransmit header in its RTSP SETUP request. The body of the header contains
the retransmit protocol name (our-retransmit) followed by a list of arguments delimited by the
semicolon character.
Currently, one argument can be passed from the client to the server: the window argument. If included,
the window argument tells the Reliable UDP server the size of the clients window in KBytes.
Here is an example:
x-Retransmit: our-retransmit;window=128
The server must echo the header and all parameters. If the x-Retransmit header is not in the SETUP
response, the client must assume that Reliable UDP will not be used for this stream. If the server
changes the parameter values, the client must use the new values.
Indicate to proxy servers that requests and replies are not to be cached
107
C H A P T E R
Concepts
Provide a way to uniquely identify request pairs so that they can be bound together to form a
full-duplex connection
Ensure that related requests connect to the same RTSP server in spite of load-balancing algorithms
such as round-robin DNS servers
Identify any request as one that will eventually tunnel an RTSP conversation and RTP data
The QuickTime HTTP transport exploits the capability of HTTPs GET and POST methods to carry
an indefinite amount of data in their reply and message body respectively. In the most simple case,
the client makes an HTTP GET request to the server to open the server-to-client connection. Then the
client makes a HTTP POST request to the server to open the client-to-server connection. The resulting
virtual full-duplex connection (shown in Figure 2-14 (page 108)) makes it possible to send unmodified
RTSP and RTP data over the connection.
Figure 1-14
Client
data
data
Server
Include in the header an x-sessioncookie directive whose value is a globally unique identifier
(GUID). The GUID makes it possible for the server to unambiguously bind the two connections
by passing it as an opaque token to the C library strcmp function
In POST requests, the application/x-rtsp-tunneled MIME type for both the Content-Type
and Accept directives must be specified; this MIME type reflects the data type that is expected
and delivered by the client and server
Direct POST requests to the specified IP address if a servers reply to an initial GET request
includes the x-server-ip-address directive and an IP address
In addition to these requirements, client HTTP POST request headers may include other directives
in order to help HTTP proxy servers handle RTSP streams optimally.
108
C H A P T E R
Concepts
Note: The server does not respond to client POST requests. The client will continue to send RTSP
data as the message body of this POST request.
The sample client POST request includes three optional header directives that are present to control
the behavior of HTTP proxy servers so that they handle RTSP streams optimally:
The Pragma: no-cache directive tells many HTTP 1.0 proxy servers not to cache the transaction.
The Cache-Control: no-cache directive tells many HTTP 1.1 proxy servers not to cache the
transaction.
The Expires directive specifies an arbitrary time in the past. This directive is intended to prevent
proxy servers from caching the transaction.
HTTP requires that all POST requests have a content-length header. In the sample client POST request,
the content length of 32767 is an arbitrary value. In practice, the actual value seems to be ignored by
proxy servers, so it is possible to send more than this amount of data in the form of RTSP requests.
The QuickTime Server ignores the content-length header.
109
C H A P T E R
Concepts
In the absence of an HTTP error, the server reply header contains 200 OK. An HTTP error in a
server reply reflects the inability of the server to form the virtual full-duplex connection; an HTTP
error does not imply an RTSP error. When an HTTP error occurs, the server simply closes the
connection.
Including the following header directives in a reply is not required but is recommended because the
directives they tell proxy servers to behave in a way that allows them to handle RTSP streams optimally:
The Date directive specifies an arbitrary time in the past. This keeps proxy servers from caching
the transaction.
The Cache-Control: no-cache directive tells many HTTP 1.1 proxy servers not to cache the
transaction.
The Pragma: no-cache directive tells many HTTP 1.0 proxy servers not to cache the transaction.
110
C H A P T E R
Concepts
Connection Maintenance
The client may close the POST connection at any time. Doing so frees socket and memory resources
at the server that might otherwise be unused for a long time. In QuickTime HTTP streaming, the best
time to close the POST connection usually occurs after the PLAY request.
111
C H A P T E R
Concepts
112
C H A P T E R
Tasks
Building the Streaming Server, described in Building the Streaming Server (page 113).
Compiling and installed a QTSS module, described in Compiling a QTSS Module into the
Server (page 114).
Getting and setting attribute values, described in Working with Attributes (page 116). This
section also tells you how to add your own attributes to an object.
Using the servers file module to open, read, and close files, described in Using Files (page 120).
This section also tells you how to implement your own file system module.
Communicating with the server with the Admin protocol, described in Using the Admin
Protocol (page 130).
Mac OS X
Use the Buildit script to build the Streaming Server for Mac OS X. Use the following command line
options: StreamingServer.pbroj -target DSS. As they are built, the binaries are left in the build
directory.
The command BuildOSXInstallerPkg dss creates a file named DarwinStreamingServer.pkg.
POSIX
Use the Buildit script to build the Streaming Server on POSIX platforms. Binaries are left in the
source directories. To create the installer, use the buildtarball script, which creates an install
directory with Install script and tar file.
113
C H A P T E R
Tasks
Windows
Use the WindowsNTSupport/StreamingServer.dsw script to build the Streaming Server on Windows
platforms. Batch build all. Binaries are left in the Debug and Release directory. The
WindowsNTSupport/makezip.bat script creates an install directory with an Install.bat file.
where XYZ is the name of your module and XYZMAIN is your modules main routine.
Some platforms require that each module use unique function names. To prevent name conflicts when
you compile a module into the server, make your functions static.
Modules that are compiled into the server are known as static modules.
114
1.
Compile the source for your module as a dynamic shared library for the platform you are targeting.
For Mac OS X, the project type must be loadable bundle.
2.
Link the resulting file against the QTSS API stub library for the platforms you are targeting.
C H A P T E R
Tasks
3.
Some platforms require that each module use unique function names. To prevent name conflicts when
the server loads your module, strip the symbols from your module before you have the server load
it.
Debugging
Several server preferences in the streamingserver.xml file are available for enabling the generation
of debugging information, which is printed on the terminal screen. The following sections provide
information on debugging:
In the previous example, rtp enables the display of RTP packet headers, rr enables the display of
RTCP receiver reports, sr enables the display of RTCP sender reports, app enables the display of
RTCP application packets, and ack enables the display of Reliable UDP RTP acknowledgement
packets.
After enabling RTSP and RTP debugging, restart the Streaming Server in debug mode using this
command:
QuickTimeStreamingServer -d
When you connect a client, debug information is displayed on the terminal screen.
Debugging
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
115
C H A P T E R
Tasks
#define TASK_DEBUG 1
116
static attributes. Static attributes are present in all instances of an object type. A module can add
static attributes to objects from its Register role only. All of the servers built-in attributes are
static attributes. For information about adding static attributes to object types, see the section
Adding Attributes (page 119)
instance attributes. Instance attributes are added to a specific instance of any object type. A module
can use any role to add an instance attribute to an object and can also remove instance attributes
that it has added to an object. For information about adding instance attributes to objects, see the
section Adding Attributes (page 119).
C H A P T E R
Tasks
Note: Adding static attributes is more efficient than adding instance attributes, so adding static
attributes instead of adding instance attributes is strongly recommended.
QTSS_GetValue, which copies the attribute value into a buffer provided by the module. This
callback can be used to get the value of any attribute, but it is not as efficient as QTSS_GetValuePtr.
QTSS_GetValueAsString, which copies the attribute value as a string into a buffer provided by
the module. This callback can be used to get the value of any attribute. This is the least efficient
way to get the value of an attribute
QTSS_GetValuePtr, which returns a pointer to the servers internal copy of the attribute value.
This is the most efficient way to get the value of preemptive safe attributes. It can also be used to
get the value of non-preemptive safe attributes, but the object must first be locked and must be
unlocked after QTSS_GetValuePtr is called. When getting the value of a single non-preemptive-safe
attribute, calling QTSS_GetValue may be more efficient than locking the object, calling
QTSS_GetValuePtr and unlocking the object.
The sample code in Listing 2-1 (page 117) calls QTSS_GetValue to get the value of the
qtssRTPSvrCurConn attribute, which is not preemptive safe, from the QTSS_ServerObject object.
Listing 2-1
The sample code in Listing 2-2 (page 117) calls QTSS_GetValuePtr, which is the preferred way to get
the value of preemptive-safe attributes. In this example, value of the qtssRTSPReqMethod attribute
is obtained from the object QTSS_RTSPRequestObject.
Listing 2-2
117
C H A P T E R
Tasks
You can obtain the value any attribute by calling QTSS_GetValueAsString, which gets the attributes
value as a C string. Calling QTSS_GetValueAsString is convenient when you dont know the type
of data the attribute contains. In Listing 2-3 (page 118), the value of the qtssRTPSvrCurConn attribute
is obtained as a string from the QTSS_ServerObject.
Listing 2-3
// First get the file path for this request using QTSS_GetValuePtr
char* theFilePath = NULL;
UInt32 theFilePathLen = 0;
QTSS_Error theErr = QTSS_GetValuePtr(inParams->inRTSPRequest, qtssRTSPReqFilePath,
0, &theFilePath,
&theFilePathLen);
// Check for any errors
if (theErr != QTSS_NoErr) return;
118
C H A P T E R
Tasks
// See if this path is a match. If it is, use QTSS_SetValue to set the root
directory for this request.
if ((theFilePathLen == sStaticFilePathLen) &&
(::strncmp(theFilePath, sStaticFilePath, theFilePathLen) ==
0))
{
theErr = QTS_SetValue(inParams->inRTSPRequest, qtssRTSPReqRootDir, 0,
sNewRootDirString,
sNewRootDirStringLen);
if (theErr != QTSS_NoErr) return;
}
Listing 2-5 (page 119) demonstrates the use of the QTSS_SetValuePtr callback. The QTSS_SetValuePtr
callback associates an attribute with the value of a modules variable. This code sample modifies the
QTSS_ServerObject object nonatomically, so it calls QTSS_LockObject to prevent other threads
from accessing the attributes of the QTSS_ServerObject before the value has been set.
Then the code sample calls QTSS_CreateObjectValue to create a QTSS_ConnectedUserObject
object as the value of the qtssSvrConnectedUsers attribute of the QTSS_ServerObject object. Then
the code sample calls QTSS_SetValuePtr to set the value of the qtssConnectionBytesSent attribute
of the QTSS_ConnectedUserObject object to the modules fBytesSent variable. Thereafter, when
any module gets the value of the qtssConnectionBytesSent attribute, it will get the current value
of the modules fBytesSent variable.
After calling QTSS_SetValuePtr, the code sample calls QTSS_UnlockObject to unlock the
QTSS_ServerObject object.
Listing 2-5
UInt32 index;
QTSS_LockObject(sServer);
QTSS_CreateObjectValue(sServer, qtssSvrConnectedUsers,
qtssConnectedUserTypeObject, &index, &fQTSSObject);
QTSS_CreateObjectValue(sServer, qtssSvrConnectedUsers,
qtssConnectedUserObjectType, &index, &fQTSSObject);
QTSS_SetValuePtr(fQTSSObject, qtssConnectionBytesSent, &fBytesSent,
sizeof(fBytesSent));
QTSS_UnlockObject(sServer);
Adding Attributes
Any module can add an attribute to a QTSS object type by calling the QTSS_AddStaticAttribute
callback routine from its Register role. Modules can also call QTSS_AddInstanceAttribute from
any role to add an attribute to an instance of an object.
119
C H A P T E R
Tasks
Note: Adding one or more attributes to an object type or to an instance of an object is the most efficient
and the recommended way for modules to store data that is specific to a particular session.
Once added, the new attribute is included in every object of that type that the server creates and its
value can be set and obtained by calling that same callback routines that set and obtain the value of
the servers built-in attributes: QTSS_SetValue, QTSS_SetValuePtr, QTSS_GetValue, and
QTSS_GetValuePtr.
Note: If you are adding attributes to an object that your module created, you must first lock the object
by calling QTSS_LockObject. When all of the attributes have been added, call QTSS_UnlockObject
to unlock the object.
The sample code in Listing 2-6 (page 120) calls QTSS_AddStaticAttribute to add an attribute to the
object QTSS_ClientSessionObject.
Listing 2-6
QTSS_Error MyRegisterRoleFunction()
{
// Add the static attribute. The third parameter is always NULL.
QTSS_Error theErr = QTSS_AddStaticAttribute(qtssClientSessionObjectType,
MySampleAttribute, NULL, qtssAttrDataTypeUInt32);
// Retrieve the ID for this attribute. This ID can be passed into
QTSS_GetValue,
// QTSS_SetValue, and QTSS_GetValuePtr.
QTSS_AttributeID theID;
theErr = QTSS_IDForAttr(qtssClientSessionObjectType, MySampleAttribute",
&theID);
// Store the attribute ID in a global for later use. Attribute IDs do not
// change while the server is running.
gMyExampleAttrID = theID;
}
Note: Attribute permissions for an added attribute (static or instance) are automatically set to readable,
writable, and preemptive safe.
Using Files
QTSS supports file system modules so that QTSS can transparently and easily work with custom file
systems. For example, a QTSS file system module can allow a QTSS module to read a custom networked
file system or a custom database. Support for reading files consists of the following:
120
QTSS file system callback routines that any module can use to open, read, and close files. Calling
the file system callback routines is described in the section Reading Files Using Callback
Routines (page 121). The QTSS file system callback routines allow QTSS to easily work with
many different file system types. A QTSS module that uses the file system callbacks for reading
all files can transparently use whatever file system is deployed on a server.
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Tasks
File system roles for which modules that implement file systems register. These roles provide a
bridge between QTSS and a specific file system. The file system roles are described in the section
Implementing a QTSS File System Module (page 122). You could, for example, write a file system
module that interfaces QTSS to a custom database or a custom networked file system.
QTSS_OpenFileObject, which is called to open a file in the local operating system. This call is
one of two callback routines that is only used when working with files.
QTSS_CloseFileObject, which is called to close a file that was opened by a previous call to
QTSS_OpenFileObject. This call is one of two callback routines that is only used when working
with files.
QTSS_Read, which is called to read data from a file objects stream that was created by a previous
call to QTSS_OpenFileObject.
QTSS_Seek, which is called to set the current position of a file objects stream.
QTSS_Advise, which is called to tell a file system module that a specified section of one of its
QTSS_RequestEvent, which is called to tell a file system module that the calling module wants
to be notified when one of the events in the specified event mask occurs. The events are when a
stream becomes readable and when a stream becomes writable.
In QTSS, a file is QTSS_Object that has its own object type, QTSS_FileObject, that allows you to use
standard QTSS callbacks (QTSS_GetValue, QTSS_GetValueAsString, and QTSS_GetValuePtr) to get
meta information about a file, such as its length and modification date. You can use standard QTSS
callbacks to store any amount of file system meta information with the file object. For example, a
module working with a POSIX file system would want to add an attribute to the file object that stores
the POSIX file system descriptor. A file object also has a QTSS stream reference that can be used when
calling QTSS stream routines that work with files, such as QTSS_Read.
The sample code in Listing 3-7 (page 121) shows how to open a file, determine the files length,
read the entire file, close the file, and return the data it contains.
Listing 2-7
Reading a file
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
121
C H A P T E R
Tasks
122
Open File Preprocess role, which the server calls in response to a module (or the server) that calls
the QTSS_OpenFileObject callback routine to open a file. If the module does not handle files of
the specified type, the module immediately returns QTSS_FileNotFound. If the module handles
the files of the specified type, it opens the file, updates a file object provided by the server and
returns QTSS_NoErr. If an error occurs during this setup period, the module returns
QTSS_RequestFailed. Once the module returns QTSS_NoErr, it should be prepared to handle
the Advise File, Read File, Request Event File and Close File roles for the opened file. The server
calls each module registered in the Open File Preprocess role until one of the called modules
returns QTSS_NoErr or QTSS_RequestFailed.
Open File role, which the server calls in response to a module (or the server) that calls the
QTSS_OpenFileObject callback routine for which all modules handling the Open File Preprocess
role return QTSS_FileNotFound. Only one module can register for the Open File role. Like modules
called for the Open File Preprocess role, the module called for the Open File role must determine
whether it can handle the specified file. It it can, it opens the file, updates the file object provided
by the server and returns QTSS_NoErr. If an error occurs during the setup process or if the module
cannot handle the specified file, the module returns QTSS_RequestFailed or QTSS_FileNotFound,
respectively.
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Tasks
A file system module should register in the Open File Preprocess role if it handles a subset of files
available on the system. For instance, a file system module that serves files out of a database may
only handle files rooted at a certain path. All other paths should fall through to other modules that
handle other paths.
A file system module should register in the Open File role if it implements the default file system on
a system. For instance, on a UNIX system the module handling the Open File Role would probably
provide an interface between the server and the standard POSIX file system.
Once a module returns QTSS_NoErr from either the Open File Role or the Open File Preprocess role,
it is responsible for the newly opened file. It should be prepared to handle the following roles on
behalf of that file:
Advise File role, which is called in response to a module (or the server) calling the QTSS_Advise
callback for a file object. The QTSS_Advise callback is made to inform the file system module that
a specific region of the file will be needed soon.
Read File role, which is called in response to a module (or the server) calling the QTSS_Read
callback for a file object. It is the responsibility of a file system module handling this role to make
a best-effort attempt to fill the buffer provided by the caller with the appropriate file data.
Request Event File role, which is called in response to a module (or the server) calling the
QTSS_RequestEvent callback on a file object.
Close File role, which is called in response to a module (or the server) calling the QTSS_Close
callback on a file object. The module should clean up any file-system and module-specific data
structures for this file. This role is always the last role a file system module will be invoked in for
a given file object.
Note: Modules do not need to explicitly register for the Advise File, Read File, Request Event File or
Close File roles in order to handle them. Instead, returning QTSS_NoErr or QTSS_RequestFailed
from one of the open file roles constitutes taking ownership for a specific file object, and therefore
means that the module has implicitly registered for those roles.
Open File Preprocess Role (page 124) which is called to process requests to open files.
Open File Role (page 124) which is the default role that is called when none of the modules
registered for the Open File Preprocess role opens the specified file.
Advise File Role (page 125) which is called to tell a file system module about the callers I/O
preferences.
Request Event File Role (page 127) which is called to request notification when a file becomes
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
123
C H A P T E R
Tasks
inPath
A pointer to a null-terminated C string containing the full path to the file that is to be opened.
inFlags
Open flags specifying whether the module that called QTSS_OpenFileObject can handle
asynchronous read operations (qtssOpenFileAsync) or expects to read the file in order from
beginning to end (qtssOpenFileReadAhead).
inFileObject
A QTSS object that the module updates if it can open the file specified by inPath.
If the file is a file the module handles, the module should do whatever work is necessary to open and
set up the file. It can use inFileObject to store any module-specific information for that file. In
addition, the module should set the value of the file objects qtssFlObjLenth and qtssFlObjModDate
attributes.
If the file is a file the module handles but an error occurs while attempting to set up the file, the module
should return QTSS_RequestFailed.
If every module registered for the Open File Preprocess role returns QTSS_FileNotFound, the server
calls the one module that is registered in the Open File role.
A module that wants to be called in the Open File Preprocess role must in its Register role call
QTSS_AddRole and specify QTSS_OpenFilePreprocess_Role as the role. Modules that register for
this role must also handle the following roles, but they do not need to explicitly register for them:
Advise File, Read File, Request Event File, and Close File.
Open File Role
The server calls the module registered for the Open File role when all modules registered for the Open
File Preprocess role have been called and have returned QTSS_FileNotFound. Only one module can
be registered for the Open File role, and that module is the first module that registers for this role
when QTSS starts up.
124
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Tasks
Like modules called for the Open File Preprocess role, it is the responsibility of a module handling
the Open File role to determine whether it handles the type of file specified to be opened. If it does
and if the file exists, the module opens the file, updates the file object provided by the server, and
returns QTSS_NoErr.
When called, the module receives a QTSS_OpenFile_Params structure, which is defined as follows:
typedef struct
{
char*
inPath;
QTSS_OpenFileFlags inFlags;
QTSS_Object
inFileObject;
} QTSS_OpenFile_Params;
inPath
A pointer to a null-terminated C string containing the full path to the file that is to be opened.
inFlags
Open flags specifying whether the module that called QTSS_OpenFileObject can handle
asynchronous read operations (qtssOpenFileAsync) or expects to read the file in order from
beginning to end (qtssOpenFileReadAhead).
inFileObject
A QTSS object that the module updates if it can open the file specified by inPath.
If the file is a file the module handles, the module should do whatever work is necessary to open and
set up the file. It can use inFileObject to store any module-specific information for that file. In
addition, the module should set the value of the file objects qtssFlObjLength and qtssFlObjModDate
attributes.
If the file is a file the module handles but an error occurs while attempting to set up the file, the module
should return QTSS_RequestFailed.
A module that wants to be called in the Open File role must in its Register role call QTSS_AddRole
and specify QTSS_OpenFile_Role as the role. Modules that register for this role must also handle the
following roles, but they do not need to explicitly register for them: Advise File, Read File, Request
Event File, and Close File.
Advise File Role
The server calls modules for the Advise File role in response to a module (or the server) calling the
QTSS_Advise callback routine for a file object in order to inform the file system module that the calling
module will soon read the specified section of the file.
When called, an Advise File role receives a QTSS_AdviseFile_Params structure, which is defined as
follows:
typedef struct
{
QTSS_Object
inFileObject;
UInt64
inPosition;
UInt32
inSize;
} QTSS_AdviseFile_Params;
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
125
C H A P T E R
Tasks
inFileObject
The file object for the opened file. The file system module uses the file object to determine the
file for which the QTSS_Advise callback routine was called.
inPosition
The offset in bytes from the beginning of the file that represents the beginning of the section
that is soon to be read.
inSize
inFileObject
The file object for the file that is to be read. The file system module uses the file object to
determine the file for which the QTSS_Read callback routine was called.
inFilePosition
The offset in bytes from the beginning of the file that represents the beginning of the section
that is to be read. The server maintains the file position as an attribute of the file object, so the
file system module does not have to cache the file position internally and can obtain the position
at any time.
ioBuffer
A pointer to the buffer in which the file system module is to place the data that is read.
ioBufLen
126
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Tasks
The file system module should make a best-effort attempt to fill the buffer pointed to by ioBuffer
with data from the file that is being read starting with the position specified by inFilePosition.
If the file was opened with the qtssOpenFileAsync flag, the module should return QTSS_WouldBlock
if reading the data will cause the thread to block. Otherwise, the module should block the thread until
all of the data has become available. When the buffer pointed to by ioBuffer is full or the end of file
has been reached, the file system module should set outLenRead to the number of bytes read and
return QTSS_NoErr.
If the read fails for any reason, the file system module handling this role should return
QTSS_RequestFailed.
File system modules do not need to explicitly register for this role.
Close File Role
The server calls modules for the Close File role in response to a module (or the server) calling the
QTSS_CloseFile callback routine for a file object in order to close a file that has been opened.
When called, a Close File role receives a QTSS_CloseFile_Params structure, which is defined as
follows:
typedef struct
{
QTSS_Object
inFileObject;
} QTSS_CloseFile_Params;
inFileObject
The file object for the file that is to be closed. The file system module uses the file object to
determine the file for which the QTSS_Close callback routine was called.
A module handling this role should dispose of any data structures that it has created for the file that
is to be closed.
This role is always the last role for which a file system module will be invoked for any given file
object.
File system modules do not need to explicitly register for this role.
Modules should always return QTSS_NoErr when they finish handling this role.
Request Event File Role
The server calls modules for the Request Event File role in response to a module (or the server) calling
the QTSS_RequestEvent callback routine. If a module or the server calls the QTSS_OpenFileObject
callback routine and specifies the qtssOpenFileAsync flag, the file system module handling that file
object may return QTSS_WouldBlock from its Read File role. When that occurs, the caller of QTSS_Read
may call QTSS_RequestEvent callback to tell the server that the caller of QTSS_Read wants to be
notified when the data becomes available for reading.
When called, a Request Event File role receives a QTSS_RequestEventFile_Params structure, which
is defined as follows:
typedef struct
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
127
C H A P T E R
Tasks
{
QTSS_Object
inFileObject;
QTSS_EventType inEventMask;
} QTSS_RequestEventFile_Params;
inFileObject
The file object for the file for which notifications are requested. The file system module uses
the file object to determine the file for which the QTSS_RequestEvent callback routine was
called.
inEventMask
A mask specifying the type of events for which notification is requested. Possible values are
QTSS_ReadableEvent and QTSS_WriteableEvent.
If the file system that the file system module is implementing supports notification, the file system
module should do whatever setup is necessary to receive an event for the file for which the
QTSS_RequestEvent callback routine was called. When the file becomes readable, the file system
module should call the QTSS_SignalStream callback routine and pass the stream reference for this
file object (which can be obtained through the file objects qtssFlObjStream attribute). Calling the
QTSS_SignalStream callback routine tells the server that the caller of QTSS_RequestEvent should
be notified that the file is now readable.
File system modules do not need to explicitly register for this role.
Modules should always return QTSS_NoErr when they finish handling this role.
128
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Tasks
}
else
{
::close(theFile);
return QTSS_RequestFailed; // Stat failed
}
// Set the file length and the modification date attributes of this file
// object before returning
(void)QTSS_SetValue(inParams->inFileObject, qtssFlObjLength, 0, &theLength,
sizeof(theLength));
(void)QTSS_SetValue(inParams->inFileObject, qtssFlObjModDate, 0, &theModDate,
sizeof(theModDate));
// Place the file reference in a custom attribute in the QTSS_FileObject.
// This way, we can easily get the file reference in other role handlers,
// such as the QTSS_ReadFile_Role and the QTSS_CloseFile_Role.
QTSS_Error theErr = QTSS_SetValue(inParams->inFileObject, sFileRefAttr, 0,
&theFile, sizeof(theFileSource));
if (theErr != QTSS_NoErr)
{
::close(theFile);
return QTSS_RequestFailed;
}
return QTSS_NoErr;
}
Using Files
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
129
C H A P T E R
Tasks
QTSS_SendEventToStream callback, called by a file system module when a file does become
readable. Calling QTSS_SendEventToStream tells the server that the caller of QTSS_RequestEvent
Request Syntax
A valid request is an absolute reference followed by the server URI. An absolute reference is a path
beginning with a forward slash character (/). A path represents the servers virtual hierarchical data
structure of containers and is expressed as a URL.
Here is the request syntax:
[absolute URL]?[parameters=values]+[command=value]+[option=value]
The following rules govern URIs:
130
An asterisk (*) in the current URL location causes each element in that location to be iterated.
C H A P T E R
Tasks
A question mark (?) indicates that options follow. Options are specified as name=value pairs
delimited by the plus (+) character.
Values can be enclosed by the double quotation characters (). Enclosing double quotation
characters is required for values that contain spaces and tabs.
These characters cannot be used: period (.), two periods (..), and semicolon (;).
Request Functionality
Requests can contain an array iterator, a name lookup, a recursive tree walk, and a filtered response.
All functions can execute in a single URI query.
Here is a request that gets the stream time scale and stream payload name for every stream in every
session:
GET /modules/admin/server/qtssSvrClientSessions/*/qtssCliSesStreamObjects?
parameters=r+command=get+filter1=qtssRTPStrTimescale+filter2=qtssRTPStrPayloadName
where
r in parameter=rt specifies a recursive walk and t specifies that data types are to be included in
the result
This request gets all server module names and their descriptions:
GET /modules/admin/server/qtssSvrModuleObjects?
parameters=r+command=get+filter2=qtssModDesc+filter1=qtssModName
The following example does a recursive search and gets all server attributes and their data types:
GET /modules/admin/server/?parameters=rt
Note: Repeated recursive searches should be avoided because they impact server performance.
The following examples return server attributes and their paths:
GET /modules/admin/server/*
GET /modules/admin/server/qtssSvrPreferences/*
131
C H A P T E R
Tasks
Data References
All elements are arrays. Single element arrays may be referenced in any of the following ways:
path/element
path/element/
path/element/*
path/element/1
The references listed above are all evaluated as the same request.
Request Options
URIs that do not include a question mark (?) default to a GET request option.
URIs that include a question mark (?) must be followed by a command=command-option request
option, where command-option is GET, SET, ADD, or DEL. URIs may also be followed by a
parameters=parameter-option that refines the action of the command option.
Request options are not case-sensitive, but request option values are case-sensitive.
The Admin Protocol ignores any request option that it does not recognize as well any request options
that a command does not require.
Command Options
The Admin Protocol recognizes the following command options:
132
C H A P T E R
Tasks
The GET command does not require any request options. If any request options were specified, they
would be ignored.
If the type option is included in the command, type checking of the server element type and the set
type is performed. If the types do not match, an error is returned and the command fails.
If the element at the end of the URL is a QTSS_Object container, the ADD command option adds the
element to the container. The following example adds 5 to the element whose name is maxcount if
the data type of maxcount is SInt16:
GET /modules/admin/?command=ADD+value=5+name=maxcount+type=SInt16
Parameter Options
Parameter options are single characters without delimiters that appear after the URL.
The Admin Protocol recognizes the following parameter options:
r Walk downward in the hierarchy starting at end of the URL. Recursion should be avoided
133
C H A P T E R
Tasks
Here is an example that uses the r and t parameter options to recursively get the data type of all
qtssSvrClientSessions:
GET /modules/admin/server/qtssSvrClientSessions?parameters=rt+command=get
Data Types
Data types can be any server-allowed text value. New data types can be defined and returned by the
server, so data types are not limited to the basic set listed here:
UInt8
SInt16 UInt64
Float64 char
SInt8
UInt32 SInt64
Bool8
QTSS_Object
void_pointer
Values of type QTSS_Object, pointers, and unknown data types always converted to a host-ordered
string of hexadecimal values. Here is an example of a hexadecimal value result:
unknown_pointer=halogen; type=void_pointer
Server Responses
This section describes the data that is returned in response to a request. The information on response
data is organized in the following sections:
134
C H A P T E R
Tasks
Unauthorized Response
Here is an example of an unauthorized response:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="QTSS/modules/admin"
Server: QTSS
Connection: Close
Content-Type: text/plain
OK Response
Here is an example of an OK response:
HTTP/1.0 200 OK
Server: QTSS/4.0 [v408]-MacOSX
Connection: Close
Content-Type: text/plain
Container="/"
admin/
error:(0)
Response Data
All entity references in response data follow this form:
[NAME=VALUE];[attribute=value],[attribute=value]
where brackets ([ ]) indicate that the enclosed response data is optional. Therefore, the response data
may take the following forms:
NAME=VALUE
NAME=VALUE;attribute=value
NAME=VALUE;attribute=value,attribute=value
All container references follow this form:
[NAME/];[attribute=value],[attribute=value]
where brackets ([ ]) indicate that the enclosed response data is optional. Therefore, response data may
take the following forms:
NAME/
135
C H A P T E R
Tasks
NAME/;attribute=value
NAME;attribute=value,attribute=value
The order of appearance of container references and the containers entity references are important.
This is especially true when the response is a recursive walk of a container hierarchy.
Each new level in the hierarchy must begin with a Container= reference. Each container list of
elements must be a complete list of the contained elements and any containers. The appearance of a
Container= reference indicates the end of a previous containers contents and the beginning of a new
container.
This example shows how each new container is identified with a unique path:
Container="/level1/"
field1="value"
field2="value"
level2a/
level2b/
Container="/level1/level2a/"
field1="value"
level3a/
level3b/
Container="/level1/level2a/level3a"
field1="value"
Container="/level1/level2a/level3b"
Container="/level1/level2b/"
field1="value"
level3a/
Container="/level1/level2b/level3a/"
field1="value"
Array Values
For arrays of elements, a numerical value represents the index. Arrays are containers. Here is an
example:
Container="/level1/"
field1="value"
field2="value"
array1/
Container="/level1/array1/"
1=value
2=value
136
C H A P T E R
Tasks
field1="value"
Response Root
The root for responses is /admin.
Errors in Responses
For each response, the error state for the request is reported at the end of the data. Here are some
examples:
Error:(0) indicates that no error occurred
Error:(404) indicates that no data was found
The number enclosed by parentheses is an HTTP error code followed by an error string when
debugging is turned on using the "parameters=d" query option. Here is an example:
error:(404);reason="No data found"
The following example uses basic authentication and shows the HTTP response headers:
Request: GET /modules/admin?parameters=a+command=get
Authorization: Basic QWXtaW5pT3RXYXRvcjXkZWZhdWx0
Response:
HTTP/1.0 200 OK
Server: QTSS/4.0 [v408]-MacOSX
Connection: Close
Content-Type: text/plain
Container="/"
admin/;a=r
error:(0)
The following recursive request gets the value of each element in /modules/admin:
GET /modules/admin?command=get+parameters=r
The following recursive request returns the access type and data type for the value of each element
in /modules/admin:
GET /modules/admin?command=get+parameters=rat
The following request gets the elements in /modules/admin. Note that the GET command option is
not required because request options are not present.
137
C H A P T E R
Tasks
GET /modules/admin/*
A request like the following can be used to monitor the session list:
GET /modules/admin/server/qtssSvrClientSessions/*
The following request gets the indexes for the qtssCliSesStreamObjects object, which is an indexed
array of streams:
GET /modules/admin/server/qtssSvrClientSessions/*/qtssCliSesStreamObjects/*
138
C H A P T E R
Tasks
qtssRTPStrFrameRate="0"
qtssRTPStrExpFrameRate="3903"
qtssRTPStrAudioDryCount="0"
qtssRTPStrIsTCP="false
qtssRTPStrStreamRef="18861508"
qtssRTPStrCurrentPacketDelay="-2"
qtssRTPStrTransportType="0"
qtssRTPStrStalePacketsDropped="0"
qtssRTPStrTimeFlowControlLifted="974373815109"
qtssRTPStrCurrentAckTimeout="0"
qtssRTPStrCurPacketsLostInRTCPInterval="52"
qtssRTPStrPacketCountInRTCPInterval="689"
QTSSReflectorModuleStreamCookie=(null)
qtssNextSeqNum=(null)
qtssSeqNumOffset=(null)
QTSSSplitterModuleStreamCookie=(null)
QTSSFlowControlModuleLossAboveTol="0"
QTSSFlowControlModuleLossBelowTol="3"
QTSSFlowControlModuleGettingWorses="0"
error:(0)
139
C H A P T E R
Tasks
The elements defined in qtssModPrefs can be added to, deleted, and modified.
A module or the server can automatically restore some deleted elements if the elements are needed
by a module or the server. When applied to a qtssModPrefs element, the ADD, DEL, and SET commands
cause the streaming servers XML preference file to be rewritten.
140
= 2,
C H A P T E R
This section describes the QTSS callback routines that modules call to obtain information from the
server, allocate and deallocate memory, create objects, get and set attribute values, and manage client
and RTSP sessions.
Parameter Descriptions
inRole
On input, a value of type QTSS_Role (page 184) that specifies the role that is to be added.
result
The QTSS_AddRole callback can only be called from a modules Register role. For this version of the
server, you can add the following roles: QTSS_ClientSessionClosing_Role, QTSS_ErrorLog_Role,
QTSS_Initialize_Role, QTSS_OpenFilePreprocess_Role, QTSS_OpenFile_Role,
141
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_New
Allocates memory.
void* QTSS_New(
FourCharCode inMemoryIdentifier,
UInt32 inSize);
Parameter Descriptions
inMemoryIdentifier
On input, a value of type FourCharCode that will be associated with this memory allocation.
The server can track the allocated memory to make debugging memory leaks easier.
inSize
On input, a value of type UInt32 that specifies in bytes the amount of memory to be allocated.
result
None.
Discussion
The QTSS_New callback routine allocates memory. QTSS modules should call QTSS_New whenever it
Parameter Descriptions
inMemory
On input, a pointer to an arbitrary value that specifies in bytes the amount of memory to be
deleted.
result
None.
Discussion
The QTSS_Delete callback routine deletes memory that was previously allocated by
QTSS_New (page 142).
142
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_Milliseconds
Gets the current value of the servers internal clock.
QTSS_TimeVal QTSS_Milliseconds();
Parameter Descriptions
result
The value of the servers internal clock in milliseconds since midnight January 1, 1970.
Discussion
The QTSS_Milliseconds callback routine gets the current value of the servers internal clock since
midnight January 1, 1970. Unless otherwise noted, all millisecond values that the server provides in
attributes are obtained from this clock.
QTSS_MilliSecsTo1970Secs
Converts a value obtained from the servers internal clock to the current time.
time_t QTSS_MilliSecsTo1970Secs(QTSS_TimeVal inQTSS_Milliseconds);
Parameter Descriptions
inQTSS_Milliseconds
143
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
outType
A result code. Possible values are QTSS_NoErr, QTSS_FailedRequest too many object types
already exist, and QTSS_OutOfState if QTSS_CreateObjectType an attribute of the specified
name already exists.
Discussion
The QTSS_CreateObjectType callback routine creates a new object type and provides a pointer to it.
Static attributes can be added to the object type by calling QTSS_AddStaticAttribute (page 147).
Instance attributes can be added to instances of objects of the new object type.
The QTSS_AddStaticAttribute callback can only be called from the Register role. Call
QTSS_SetValue (page 156) to set the value of an added attribute and QTSS_RemoveValue (page 155)
to remove the value of an added attribute.
This callback may only be called from the Register role.
QTSS_CreateObjectValue
Creates a new object that is the value of another objects attribute.
QTSS_Error QTSS_CreateObjectValue(
QTSS_Object inObject,
QTSS_AttributeID inID,
QTSS_ObjectType inType,
UInt32* outIndex,
QTSS_Object* outCreatedObject);
Parameter Descriptions
inObject
On input, a pointer to a value of type QTSS_ObjectType (page 183) that specifies the object
having an attribute whose value will be the created object.
inID
On input, a value of type QTSS_AttributeID (page 183) that specifies the attribute ID of the
attribute whose value will be the created object.
inType
On input, a value of type QTSS_ObjectType (page 183) that specifies the object type of the
object that is to be created.
outIndex
On output, a pointer to a value of type UInt32 that contains the index of the created object.
outCreatedObject
On output, a pointer to a value of type QTSS_ObjectType (page 183)s that is the new object.
144
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr, QTSS_BadArgument if any parameter is invalid,
and QTSS_ReadOnly if the attribute specified by inID is a read-only attribute.
Discussion
The QTSS_CreateObjectValue callback routine creates an object that is the value of an existing objects
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object that is to be locked.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if the specified object
instance does not exist.
Discussion
The QTSS_LockObject callback routine locks the specified object so that accesses to the objects
attributes from other threads will block. Call QTSS_LockObject before performing non-atomic updates
on a variable that is pointed to by an attributeas set by calling QTSS_SetValuePtr (page 156)or
Parameter Descriptions
inObject
145
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if the specified object
is not a valid object.
Discussion
The QTSS_UnLockObject callback routine unlocks an object that was previously locked by
QTSS_LockObject (page 145).
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object to which the instance
attribute is to be added.
inAttrName
On input, a pointer to a byte array that specifies the name of the attribute that is to be added.
inUnused
Always NULL.
QTSS_AttrDataType
On input, a value of type QTSS_AttrDataType (page 175) that specifies the data type of the
attribute that is being added.
result
146
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
When adding attributes to an object that a module as created, you must lock the object first by calling
QTSS_LockObject (page 145). Add the attributes and then call QTSS_UnLockObject (page 145).
All added instance attributes have values that are implicitly readable, writable, and preemptive safe,
so their values can be obtained by calling QTSS_GetValueAsString (page 152) and
QTSS_GetValuePtr (page 153). You can also call QTSS_GetValue (page 151) to get the value of an added
static attribute, but doing so is less efficient.
Adding static attributes is more efficient than adding instance attributes, so adding static attributes
instead of adding instance attributes is strongly recommended.
Typically, a module adds an instance attribute and sets its value by calling QTSS_SetValue (page 156)
when it is first installed to add its default preferences to its module preferences object. On subsequent
runs of the server, the preferences will already exist in the modules module preferences object, so
the module only needs to call QTSS_GetValue (page 151), QTSS_GetValueAsString (page 152), or
QTSS_GetValuePtr (page 153) to get the value. Calling QTSS_GetValuePtr is the most efficient and
recommended way to get the value of an attribute. Calling QTSS_GetValue is less efficient than calling
QTSS_GetValuePtr, and calling QTSS_GetValueAsString is less efficient than calling QTSS_GetValue.
Call QTSS_RemoveValue (page 155) to remove the value of an added attribute.
Unlike static attributes, instance attributes can be removed. To remove an instance attribute from the
instance of an object, call QTSS_RemoveInstanceAttribute (page 154).
QTSS_AddStaticAttribute
Adds a static attribute to an object type.
QTSS_Error QTSS_AddStaticAttribute(
QTSS_ObjectType inObjectType,
const char* inAttributeName,
void* inUnused,
QTSS_AttrDataType inAttrDataType);
Parameter Descriptions
inType
On input, a value of type QTSS_ObjectType (page 183) that specifies the type of object to which
the attribute is to be added.
inAttributeName
On input, a pointer to a byte array that specifies the name of the attribute that is to be added.
inUnused
Always NULL.
QTSS_AttrDataType
On input, a value of type QTSS_AttrDataType (page 175) that specifies the data type of the
attribute that is being added.
147
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object having the attribute
for which information is to be obtained.
inAttrID
On input, a value of type QTSS_AttributeID (page 183) that specifies the attribute for which
information is to be obtained.
outAttrInfoObject
148
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr, QTSS_BadArgument if the specified object does
not exist, and QTSS_AttrDoesntExist if the attribute doesnt exist.
Discussion
The QTSS_GetAttrInfoByID callback routine uses an attribute ID to get an QTSS_AttrInfoObject
that can be used to get the attributes name, data type, permissions for reading and writing the
attributes value, and whether getting the attributes value is preemptive safe.
QTSS_GetAttrInfoByIndex
Gets information about all of an objects attributes by iteration.
QTSS_Error QTSS_GetAttrInfoByIndex(
QTSS_Object inObject,
UInt32 inIndex,
QTSS_AttrInfoObject* outAttrInfoObject);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object having the attribute
for which information is to be obtained.
inIndex
On input, a value of type UInt32 that specifies the index of the attribute for which information
is to be obtained. Start by setting inIndex to zero. For the next call to
QTSS_GetAttrInfoByIndex, increment inIndex by one to get information for the next attribute.
Call QTSS_GetNumAttributes (page 150) to get the number of attributes that inObject has.
outAttrInfoObject
A result code. Possible values are QTSS_NoErr, QTSS_BadArgument if the specified object does
not exist, and QTSS_AttrDoesntExist if the attribute doesnt exist.
Discussion
The QTSS_GetAttrInfoByIndex callback routine uses an index to get an QTSS_AttrInfoObject that
can be used to get the attributes name and ID, data type, permissions for reading and write the
attributes value, and whether getting the attributes value is preemptive safe
The QTSS_GetAttrInfoByIndex callback routine returns a QTSS_AttrInfoObject for both static
and instance attributes.
QTSS_GetAttrInfoByName
Uses an attributes name to get information about an attribute.
149
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_Error QTSS_GetAttrInfoByName(
QTSS_Object inObject,
char* inAttrName,
QTSS_AttrInfoObject* outAttrInfoObject);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object having the attribute
for which information is to be obtained.
inAttrName
On input, a pointer to a C string containing the name of the attribute for which information is
to be obtained.
outAttrInfoObject
A result code. Possible values are QTSS_NoErr, QTSS_BadArgument if the specified object does
not exist, and QTSS_AttrDoesntExist if the attribute doesnt exist.
Discussion
The QTSS_GetAttrInfoByName callback routine uses an attribute name to get an
QTSS_AttrInfoObject that can be used to get the attributes ID, its data type, and permissions for
reading and writing the attributes value, and whether getting the attributes value is preemptive
safe.
The QTSS_GetAttrInfoByName callback routine returns a QTSS_AttrInfoObject for both static and
instance attributes.
QTSS_GetNumAttributes
Gets a count of an objects attributes.
QTSS_Error QTSS_GetNumAttributes(
QTSS_Object inObject,
UInt32* outNumAttributes);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object whose attributes are
to be counted.
outNumAttributes
On output, a pointer to a value of type UInt32 that contains the count of the objects attributes.
150
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if the specified object
does not exist.
Discussion
The QTSS_GetNumAttributes callback routine gets the number of attributes for the object specified
by inObject. Having the number of attributes lets you know how often to call
QTSS_GetAttrInfoByIndex (page 149) when getting information about each of an objects attributes.
QTSS_GetValue
Copies the value of an attribute into a buffer.
QTSS_Error QTSS_GetValue (
QTSS_Object inObject,
QTSS_AttributeID inID,
UInt32 inIndex,
void* ioBuffer,
UInt32* ioLen);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) specifying the object that contains the attribute
whose value is to be obtained.
inID
On input, a value of type QTSS_AttributeID (page 183) specifying the ID of the attribute whose
value is to be obtained.
inIndex
On input, a value of type UInt32 that specifies which attribute value to get (if the attribute can
have multiple values) or zero for single-value attributes.
ioBuffer
On input, a pointer to a buffer. On output, the buffer pointed to by ioBuffer contains the
value of the attribute specified by inID. If the buffer is too small to contain the value, the buffer
is empty.
ioLen
On input, a pointer to a value of type UInt32 specifying the length of the buffer pointed to by
ioBuffer. On output, ioLen points to a value that is the length of the valid data in ioBuffer.
result
151
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Discussion
The QTSS_GetValue callback routine copies the value of the specified attribute into the provided
buffer.
Calling QTSS_GetValue is slower and less efficient than calling QTSS_GetValuePtr (page 153).
QTSS_GetValueAsString
Gets the value of an attribute as a C string.
QTSS_Error QTSS_GetValueAsString (
QTSS_Object inObject,
QTSS_AttributeID inID,
UInt32 inIndex,
char** outString);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) specifying the object that contains the attribute
whose value is to be obtained.
inID
On input, a value of type QTSS_AttributeID (page 183) specifying the ID of the attribute whose
value is to be obtained.
inIndex
On input, a value of type UInt32 specifying which attribute value to get (if the attribute can
have multiple values) or zero for single-value attributes.
outString
When you no longer need outString, call QTSS_Delete (page 142) to free the memory that has been
allocated for it.
The QTSS_GetValueAsString callback routine can be called to get the value of preemptive safe
attributes as well as attributes that are not preemptive safe. However, calling QTSS_GetValueAsString
is less efficient than calling QTSS_GetValue (page 151), and calling QTSS_GetValue is less efficient
than calling QTSS_GetValuePtr (page 153).
152
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Calling QTSS_GetValue is the recommended way to get the value of an attribute that is not preemptive
safe and calling QTSS_GetValuePtr is the recommended way to get the value of an attribute that is
preemptive safe.
QTSS_GetValuePtr
Gets a pointer to an attributes value.
QTSS_Error QTSS_GetValuePtr (
QTSS_Object inObject,
QTSS_AttributeID inID,
UInt32 inIndex,
void** outBuffer,
UInt32* outLen);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) specifying the object containing the attribute
whose value is to be obtained.
inID
On input, a value of type UInt32 specifying which attribute value to get (if the attribute can
have multiple values) or zero for single-value attributes.
outBuffer
On input, a pointer to an address in memory. On output, outBuffer points to the value of the
attribute.
outLen
On output, a pointer to a value of type UInt32 specifying the number of valid bytes pointed
to by outBuffer.
result
153
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
If you dont want to lock and unlock the object to get the value of an attribute that is not preemptive
safe, get the value by calling QTSS_GetValue (page 151) or QTSS_GetValueAsString (page 152).
QTSS_IDForAttr
Gets the ID of a static attribute.
QTSS_Error QTSS_IDForAttr(
QTSS_ObjectType inType,
const char* inAttributeName,
QTSS_AttributeID* outID);
Parameter Descriptions
inType
On input, a value of type QTSS_ObjectType (page 183) specifying the type of object for which
the ID is to be obtained.
inAttributeName
On input, a pointer to a byte array specifying the name of the attribute whose ID is to be
obtained.
outID
On input, a pointer to a value of type QTSS_AttributeID (page 183). On output, outID points
to the ID of the attribute specified by inAttributeName.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
Discussion
The QTSS_IDForAttr callback routine obtains the attribute ID for the specified static attribute in the
specified object type. The attribute ID is used to when calling QTSS_GetValue (page 151),
QTSS_GetValueAsString (page 152), and QTSS_GetValuePtr (page 153) get the attributes value.
154
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object from which the
instance attribute is to be removed.
inID
On input, a value of typeQTSS_AttributeID (page 183) that specifies the ID of the attribute
that is to be removed.
result
A result code. Possible values are QTSS_NoErr, QTSS_BadArgument if the specified object
instance does not exist, and QTSS_AttrDoesntExist if the attribute doesnt exist.
Discussion
The QTSS_RemoveInstanceAttribute callback routine removes the attribute specified by the inID
parameter from the instance of an object specified by the inObject parameter.
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) having an attribute whose value is to be
removed.
inValueLen
On input, a value of type QTSS_AttributeID (page 183) containing the attribute ID of the
attribute whose value is to be removed.
inIndex
On input, a value of type UInt32 that specifies the attribute value that is to be removed.
Attribute value indexes are numbered starting from zero.
result
155
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_SetValue
Sets the value of an attribute.
QTSS_Error QTSS_SetValue (
QTSS_Object inObject,
QTSS_AttributeID inID,
UInt32 inIndex,
const void* inBuffer,
UInt32 inLen);
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object containing the
attribute whose value is to be set.
inID
On input, a value of type QTSS_AttributeID (page 183) that specifies the ID of the attribute
whose value is to be set.
inIndex
On input, a value of type UInt32 that specifies which attribute value to set (if the attribute can
have multiple values) or zero for single-value attributes.
inBuffer
On input, a pointer to a buffer containing the value that is to be set. When QTSS_SetValue
returns, you can dispose of inBuffer.
inLen
On input, a pointer to a value of type UInt32 that specifies the length of valid data in inBuffer.
result
A result code. Possible values are QTSS_NoErr, QTSS_BadIndex if the index specified by inIndex
does not exist, QTSS_BadArgument if a parameter is invalid, QTSS_ReadOnly if the attribute is
read-only, and QTSS_AttrDoesntExist if the attribute doesnt exist.
Discussion
The QTSS_SetValue callback routine explicitly sets the value of the specified attribute. Another way
to set the value of an attribute is to call QTSS_SetValuePtr (page 156).
QTSS_SetValuePtr
Sets an existing variable as the value of an attribute.
QTSS_Error QTSS_SetValue (
QTSS_Object inObject,
QTSS_AttributeID inID,
const void* inBuffer,
UInt32 inLen);
156
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
inObject
On input, a value of type QTSS_Object (page 183) that specifies the object containing the
attribute whose value is to be set.
inID
On input, a value of type QTSS_AttributeID (page 183) that specifies the ID of the attribute
whose value is to be set.
inBuffer
On input, a pointer to a value of type UInt32 that specifies the length of valid data in inBuffer.
result
After calling QTSS_SetValuePtr, the module must insure that the buffer pointed to by inBuffer
exists as long as the attribute specified by inID exists.
If the buffer pointed to by inBuffer is not updated atomically, updating the value of inBuffer should
be protected by calling QTSS_LockObject (page 145) before an update.callback
QTSS_StringToValue
Converts an attribute data type in C string format to a value in QTSS_AttrDataType format.
QTSS_Error QTSS_StringToValue(
const char* inValueAsString,
const QTSS_AttrDataType inType,
void* ioBuffer,
UInt32* ioBufSize);
Parameter Descriptions
inValueAsString
On input, a value of type QTSS_AttrDataType (page 175) that specifies the attribute data type
to which the value pointed to by inValueAsString is to be converted.
157
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
ioBuffer
On input, a pointer to a buffer. On output, the buffer contains the attribute data type to which
inValueAsString has been converted. The calling module must allocate ioBuffer before calling
QTSS_StringToValue.
ioBufSize
On input, a pointer to a value of type UInt32 that specifies the length of the buffer
pointed to by ioBuffer. On output, ioBufSize points to the length of data in ioBuffer.
result
When the memory allocated for the buffer pointed to by ioBuffer is no longer needed, you should
deallocate the memory.
QTSS_TypeStringToType
Gets the attribute data type of a data type string that is in C string format.
QTSS_Error QTSS_TypeStringToType(
const char* inTypeString,
QTSS_AttrDataType* outType);
Parameter Descriptions
inTypeString
On input, a pointer to a character array containing the attribute data type in C string format.
outType
On output, a pointer to a value of type QTSS_AttrDataType (page 175) containing the attribute
data type.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if inTypeString does
not contain a value for which an attribute data type can be returned.
Discussion
The QTSS_TypeStringToType callback routine gets the attribute data type of a data type string that
is in C string format.
QTSS_TypeToTypeString
Gets the name in C string format of an attribute data type.
158
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_Error QTSS_TypeToTypeString(
const QTSS_AttrDataType inType,
char** outTypeString);
Parameter Descriptions
inType
On input, a pointer to a value of type QTSS_AttrDataType (page 175) containing the attribute
data type that is to be returned in C string format.
outType
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if inType does not
contain a valid attribute data type.
Discussion
The QTSS_TypeToTypeString callback routine gets the name in C string format of a value that is in
QTSS_AttrDataType format.
QTSS_ValueToString
Converts an attribute data type in QTSS_AttrDataType format to a value in C string format.
QTSS_Error QTSS_ValueToString(
const void* inValue,
const UInt32 inValueLen,
const QTSS_AttrDataType inType,
char** outString);
Parameter Descriptions
inValue
On input, a value of type UInt32 that specifies the length of the value pointed to by inValue.
inType
On input, a value of type QTSS_AttrDataType (page 175) that specifies the attribute data type
of the value pointed by inValue.
outString
On output, a pointer to a location in memory containing the attribute data type in C string
format.
159
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if inValue, inValueLen,
or inType do not contain valid values.
Discussion
The QTSS_ValueToString callback routine converts an attribute data type in QTSS_AttrDataType
Parameter Descriptions
inRef
On input, the offset in bytes from the beginning of the stream that marks the beginning of the
advise section.
inAdviseSize
will be read soon. The file system module may read ahead in order to respond more quickly to future
calls to QTSS_Read for the specified stream.
QTSS_Read
Reads data from a stream.
160
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_Error QTSS_Read(
QTSS_StreamRef inRef,
void* ioBuffer,
UInt32 inBufLen,
UInt32* outLengthRead);
Parameter Descriptions
inRef
On input, a value of type QTSS_StreamRef (page 185) that specifies the stream from which
data is to be read. Call QTSS_OpenFileObject to obtain a stream reference for the file you want
to read.
ioBuffer
On input, a value of type UInt32 that specifies the length of the buffer pointed to by ioBuffer.
outLenRead
On output, a pointer to a value of type UInt32 that contains the number of bytes that were
read.
result
QTSS_Seek
Sets the position of a stream.
QTSS_Error QTSS_Seek(
QTSS_StreamRef inRef,
UInt64 inNewPosition);
Parameter Descriptions
inRef
On input, a value of type QTSS_StreamRef (page 185) QTSS_StreamRef that specifies the stream
whose position is to be set. Call QTSS_OpenFileObject to obtain stream reference.
inNewPosition
On input, the offset in bytes from the start of the stream to which the position is to be set.
161
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
QTSS_RequestEvent
Requests notification of specified events.
QTSS_Error QTSS_RequestEvent(
QTSS_StreamRef inStream,
QTSS_EventType inEventMask);
Parameter Descriptions
inStream
On input, a value of type QTSS_StreamRef (page 185) that specifies the stream for which event
notifications are requested.
inEventMask
On input, a value of type QTSS_EventType (page 178) specifying a mask that represents the
events for which notifications are requested.
result
as possible from its current module role. The server preserves the calling modules current state and,
when the event occurs, calls the module in the role the module was in when it called
QTSS_RequestEvent.
QTSS_SignalStream
Notifies the recipient of events that a stream has become available for I/O.
QTSS_Error QTSS_RequestEvent(
QTSS_StreamRef inStream,
QTSS_EventType inEventMask);
Parameter Descriptions
inStream
On input, a value of type QTSS_StreamRef (page 185) specifying the stream that has become
available for I/O.
162
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
inEventMask
On input, a value of type QTSS_EventType (page 178) containing a mask that represents whether
the stream has become available for reading, writing, or both.
result
has become available for I/O. Currently only file system modules have reason to call
QTSS_SignalStream.
QTSS_Write
Writes data to a stream.
QTSS_Error QTSS_Write(
QTSS_StreamRef inRef,
void* inBuffer,
UInt32 inLen,
UInt32* outLenWritten,
UInt32 inFlags);
Parameter Descriptions
inRef
On input, a value of type QTSS_StreamRef (page 185) that specifies the stream to which data
is to be written.
inBuffer
On input, a value of type UInt32 that specifies the length of the data in the buffer pointed to
by ioBuffer.
outLenWritten
On output, a pointer to a value of type UInt32 that contains the number of bytes that were
written.
inFlags
On input, a value of type UInt32. See the Discussion section for possible values.
result
163
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Discussion
The QTSS_Write callback routine writes a buffer of data to a stream.
These flags are relevant when writing to an RTP stream reference and tell the server whether the data
written should be sent over the RTP channel (qtssWriteFlagsIsRTP) or over the RTCP channel of
the specified RTP stream (qtssWriteFlagsIsRTCP).
QTSS_WriteV
Writes data to a stream using an iovec structure.
QTSS_Error QTSS_WriteV(
QTSS_StreamRef inRef,
iovec* inVec,
UInt32 inNumVectors,
UInt32 inTotalLength,
UInt32* outLenWritten);
Parameter Descriptions
inRef
On input, a value of type QTSS_StreamRef (page 185) that specifies the stream to which data
is to be written.
inVec
On input, a pointer to an iovec structure. The first member of the iovec structure must be
empty.
inNumVectors
On output, a pointer to a value of type UInt32 containing the number of bytes that were written.
result
164
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_Flush
Forces an immediate write operation.
QTSS_Error QTSS_Flush(QTSS_StreamRef inRef);
Parameter Descriptions
inRef
On input, a value of type QTSS_StreamRef (page 185) that specifies the stream for which
buffered data is to be written.
result
Parameter Descriptions
inPath
On input, a pointer to a null-terminated C string containing the full path to the file in the local
file system that is to be opened.
inFlags
On input, a value of type QTSS_OpenFileFlags (page 178) specifying flags that describe how
the file is to be opened.
outFileObject
On output, a pointer to a value of type QTSS_Object (page 183) in which the file object for the
opened file is to be placed.
165
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
One of the attributes of the file object is a stream reference that is passed to QTSS stream callback
routines to read and write data to the file and to perform other file operations.
QTSS_CloseFileObject
Closes a file.
QTSS_Error QTSS_CloseFileObject(QTSS_Object inFileObject);
Parameter Descriptions
inFileObject
On input, a value of type QTSS_Object (page 183) that represents the file that is to be closed.
result
Parameter Descriptions
inServiceName
On input, a pointer to a string containing the name of the service that is being added.
inFunctionPtr
On input, a pointer to the module that provides the service that is being added.
166
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
call.
This callback can only be called from the Register role.
QTSS_IDForService
Resolves a service name to a service ID.
QTSS_Error QTSS_IDForService(
const char* inTag,
QTSS_ServiceID* outID);
Parameter Descriptions
inTag
On input, a pointer to a string containing the name of the service that is to be resolved.
outID
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
Discussion
The QTSS_IDForService callback routine returns in the outID parameter the service ID of the service
specified by the inTag parameter. You can use the service ID to call QTSS_DoService (page 167) to
invoke the service that serviceID represents.
QTSS_DoService
Invokes a service.
QTSS_Error QTSS_DoService(
QTSS_ServiceID inID,
QTSS_ServiceFunctionArgsPtr inArgs);
167
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
inID
On input, a value of type QTSS_ServiceID (page 184) that specifies the service that is to be
invoked. Call QTSS_IDForAttr (page 154) to get the service ID of the service you want to
invoke.
inArgs
Parameter Descriptions
inRef
On input, a value of type UInt32 containing the length of valid data pointed to by inValue.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
168
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Discussion
The QTSS_AppendRTSPHeader callback routine appends headers to an RTSP header. After calling
QTSS_AppendRTSPHeader, call QTSS_SendRTSPHeaders (page 169) to send the entire header.
QTSS_SendRTSPHeaders
Sends an RTSP header.
QTSS_Error QTSS_SendRTSPHeaders(QTSS_RTSPRequestOjbect inRef);
Parameter Descriptions
inRef
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
Discussion
The QTSS_SendRTSPHeaders callback routine sends an RTSP header. When a module calls
QTSS_SendRTSPHeaders, the server sends a proper RTSP status line, using the requests current status
code. The server also sends the proper CSeq header, session ID header, and connection header.
QTSS_SendStandardRTSPResponse
Sends an RTSP response to a client.
QTSS_Error QTSS_SendStandardRTSPResponse(
QTSS_RTSPRequestObject inRTSPRequest,
QTSS_Object inRTPInfo,
UInt32 inFlags);
Parameter Descriptions
inRTSPRequest
169
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Discussion
The QTSS_SendStandardRTSPResponse callback routine writes a standard response to the stream
specified by the inRTSPRequest parameter. The actual response that is sent depends on the method.
The following enumeration defines the qtssPlayRespWriteTrackInfo constant for the inFlags
parameter:
enum
{
qtssPlayRespWriteTrackInfo = 0x00000001
};
DESCRIBE. This response method writes status line, CSeq, SessionID, Connection headers as
determined by the request. Writes a Content-Base header with the content base being the URL
provided. Writes a Content-Type header of application/sdp. The inRTPInfo parameter must
be a QTSS_ClientSessionObject.
ANNOUNCE. This response method writes status line, CSeq, and Connection headers as
determined by the request. The inRTPInfo parameter must be a QTSS_ClientSessionObject.
SETUP. This response method writes status line, CSeq, SessionID, Connection headers as
determined by the request. Writes a Transport header with client and server ports (if the connection
is over UDP). The inRTPInfo parameter must be a QTSS_RTPStreamObject.
PLAY. This response method writes status line, CSeq, SessionID, Connection headers as determined
by the request. The inRTPInfo parameter must be a QTSS_ClientSessionObject. Set the inFlags
parameter to qtssPlayRespWriteTrackInfo to specify that you want the server to append the
sequence number, timestamp, and SSRC information to the RTP-Info header.
PAUSE. This response method writes status line, CSeq, SessionID, Connection headers as
determined by the request. The inRTPInfo parameter must be a QTSS_ClientSessionObject.
TEARDOWN. This response method writes status line, CSeq, SessionID, Connection headers as
determined by the request. The inRTPInfo parameter must be a QTSS_ClientSessionObject.
170
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
inClientRequest
On input, a value of type QTSS_ClientSessionObject identifying the client session for which
the sending of RTP packets is to be enabled.
inRTSPRequest
On input, a value of type QTSS_AddStreamFlags (page 177) that specifies stream options.
result
Parameter Descriptions
inClientSession
On input, a value of type QTSS_ClientSessionObject that identifies the client session for which
the sending of RTP packets was enabled by previously calling QTSS_AddRTPStream (page 170).
inRTSPRequest
171
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid,
and QTSS_RequestFailed if no streams have been added to the session.
Discussion
The QTSS_Play callback routine starts playing streams associated with the specified client session.
The module that called QTSS_AddRTPStream (page 170) is the only module that can call QTSS_Play.
Before calling QTSS_Play, the module should set the following attributes of the QTSS_RTPStreamObject
object for this RTP stream:
qtssRTPStrFirstSeqNumber, which should be set to the sequence number of the first packet
after the last PLAY request was issued. The server uses the sequence number to generate a proper
RTSP PLAY response.
qtssRTPStrFirstTimestamp, which should be set to the timestamp of the first RTP packet
generated for this stream after the last PLAY request was issued. The server uses the timestamp
to generate a proper RTSP PLAY response.
After calling QTSS_Play, the module is invoked in the RTP Send Packets role.
Call QTSS_Pause (page 172) to pause playing or call QTSS_Teardown (page 172) to close the client
session.
QTSS_Pause
Pauses a stream that is playing.
QTSS_Error QTSS_Pause(QTSS_ClientSessionObject inClientSession);
Parameter Descriptions
inClientSession
On input, a value of type QTSS_ClientSessionObject that identifies the client session that is
to be paused.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
Discussion
The QTSS_Pause callback routine pauses playing for a stream. The module that called
QTSS_AddRTPStream (page 170) is the only module that can call QTSS_Pause.
QTSS_Teardown
Closes a client session.
172
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
Parameter Descriptions
inClientSession
On input, a value of type QTSS_ClientSessionObject that identifies the client session that is
to be closed.
result
A result code. Possible values are QTSS_NoErr and QTSS_BadArgument if a parameter is invalid.
Discussion
The QTSS_Teardown callback routine closes a client session.
The module that called QTSS_AddRTPStream (page 170) is the only module that can call QTSS_Teardown.
Calling QTSS_Teardown causes the calling module to be invoked in the Client Session Closing role
for the session identified by the inClientSession parameter.
173
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
174
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
QTSS_AttrDataType
Each QTSS attribute has an associated data type. The QTSS_AttrDataType enumeration defines values
for attribute data types. Having an attributes data type helps the server and modules handle an
attribute value without having specific knowledge about the attribute.
typedef UInt32 QTSS_AttrDataType;
enum
{
qtssAttrDataTypeUnknown
= 0,
qtssAttrDataTypeCharArray
= 1,
qtssAttrDataTypeBool16
= 2,
qtssAttrDataTypeSInt16
= 3,
qtssAttrDataTypeUInt16
= 4,
qtssAttrDataTypeSInt32
= 5,
qtssAttrDataTypeUInt32
= 6,
qtssAttrDataTypeSInt64
= 7,
qtssAttrDataTypeUInt64
= 8,
qtssAttrDataTypeQTSS_Object = 9,
qtssAttrDataTypeQTSS_StreamRef= 10,
qtssAttrDataTypeFloat32
= 11,
qtssAttrDataTypeFloat64
= 12,
qtssAttrDataTypeVoidPointer = 13,
qtssAttrDataTypeTimeVal
= 14,
qtssAttrDataTypeNumTypes
= 15
};
Constant Descriptions
qtssAttrDataTypeUnknown
175
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
qtssAttrDataTypeUInt16
QTSS_AttrPermission
The QTSS_AttrPermission data type is an enumeration that defines values used to indicate whether
an attribute is readable, writable, or preemptive safe. The data type of the qtssAttrPermissions
attribute of the QTSS_AttrInfoObject object type is of type QTSS_AttrPermission.
typedef UInt32 QTSS_AttrPermission;
enum
{
qtssAttrModeRead
= 1,
qtssAttrModeWrite
= 2,
qtssAttrModePreempSafe= 4
};
Constant Descriptions
qtssAttrModeRead
176
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
qtssAttrModePrempSafe
QTSS_AddStreamFlags
The QTSS_AddStreamFlags enumeration defines flags that specify stream options when adding RTP
streams.
enum
{
qtssASFlagsAllowDestination
qtssASFlagsForceInterleave
= 0x00000001,
= 0x00000002
};
typedef UInt32 QTSS_AddStreamFlags;
Constant Descriptions
qtssASFlagsAllowDestination
qtssASFlagsForceInterleave
Requires interleaving.
QTSS_CliSesTeardownReason
The QTSS_CliSesTeardownReason enumeration defines values that describe why a session is closing.
The QTSS_RTPSessionState enumeration is defined as
enum
{
qtssCliSesTearDownClientRequest = 0,
qtssCliSesTearDownUnsupportedMedia = 1,
qtssCliSesTearDownServerShutdown = 2,
qtssCliSesTearDownServerInternalErr = 3
};
typedef UInt32 QTSS_CliSesTeardownReason;
Constant Descriptions
qtssCliSesTearDownClientRequest
177
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
QTSS_EventType
A QTSS_EventType is an unsigned 32-bit integer whose value uniquely identifies stream I/O events.
enum
{
QTSS_ReadableEvent
QTSS_WriteableEvent
= 1,
= 2
};
typedef UInt32 QTSS_EventType;
Constant Descriptions
QTSS_ReadableEvent
QTSS_OpenFileFlags
A QTSS_OpenFileFlags is an unsigned 32-bit integer whose value describes how a file is to be opened.
enum
{
qtssOpenFileNoFlags = 0,
qtssOpenFileAsync
= 1,
qtssOpenFileReadAhead= 2
};
typedef UInt32 QTSS_OpenFileFlags;
Constant Descriptions
qtssOpenFileNoFlags
The file stream will be read asynchronously. Reads may return QTSS_WouldBlock. Modules
that open files with qtssOpenFileAsync should call QTSS_RequestEvent (page 162) to be
notified when data is available for reading.
qtssOpenReadAhead
The file stream will be read in order from beginning to end. The file system module may read
ahead in order to respond more quickly to future read calls.
QTSS_RTPPayloadType
The QTSS_RTPPayloadType enumeration defines values that a module uses to specify the streams
payload type when it adds an RTP stream to a client session. The enumeration is defined as
enum
{
qtssUnknownPayloadType = 0,
qtssVideoPayloadType = 1,
qtssAudioPayloadType = 2
};
typedef UInt32 QTSS_RTPPayloadType;
178
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
Constant Descriptions
qtssUnknownPayloadType
QTSS_RTPNetworkMode
The QTSS_RTPNetworkMode enumeration defines values that describe the RTP network mode. These
values are set as the value of the qtssRTPStrNetworkMode and qtssRTSPReqNetworkMode attributes
of objects of type qtssRTPStreamObjectType and qtssRTSPRequestObjectType, respectively. The
QTSS_RTPNetworkMode enumeration is defined as
enum
{
qtssRTPNetworkModeDefault = 0,
qtssRTPNetworkModeMulticast = 1,
qtssRTPNetworkModeUnicast= 2
};
typedef UInt32 QTSS_RTPNetworkModes;
Constant Descriptions
qtssRTPNetworkModeDefault
QTSS_RTPSessionState
The QTSS_RTPSessionState enumeration defines values that identify the state of an RTP session.
The QTSS_RTPSessionState enumeration is defined as
enum
{
qtssPausedState = 0,
qtssPlayingState = 1
};
typedef UInt32 QTSS_RTPSessionState;
Constant Descriptions
qtssPausedState
179
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
QTSS_RTPTransportType
The QTSS_RTPTransportType enumeration defines values for RTP transports. The enumeration is
defined as
enum
{
qtssRTPTransportTypeUDP
= 0,
qtssRTPTransportTypeReliableUDP= 1,
qtssRTPTransportTypeTCP
= 2
};
typedef UInt32 QTSS_RTPTransportType;
Constant Descriptions
qtssRTPTransportTypeUDP
QTSS_RTSPSessionType
The QTSS_RTSPSessionType enumeration defines values that specify RTSP session types. The
enumeration is defined as
enum
{
qtssRTSPSession
= 0,
qtssRTSPHTTPSession
= 1,
qtssRTSPHTTPInputSession= 2
};
typedef UInt32 QTSS_RTSPSessionType;
Constant Descriptions
qtssRTSPSession
The session is the input half of an RTSP session tunneled over HTTP.
Discussion
QTSS_ServerState
The QTSS_ServerState enumeration defines values that describe the servers state. Modules can set
the servers state by setting the value of the qtssSvrState attribute in the QTSS_ServerObject object.
The enumeration is defined as
180
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
enum
{
qtssStartingUpState
= 0,
qtssRunningState
= 1,
qtssRefusingConnectionsState= 2,
qtssFatalErrorState
= 3,
qtssShuttingDownState
= 4,
qtssIdleState
= 5
};
typedef UInt32 QTSS_ServerState;
Constant Descriptions
qtssStartingUpState
Setting the server to this state causes the server to refuse new connections.
qtssFatalErrorState
Setting the server to this state causes the server to quit. When the server is running in the
background, setting the server to this state causes the server to quit and restart (Mac OS X and
POSIX platforms).
qtssShuttingDownState
Setting the server to this state causes the server to refuse new connections and disconnect
existing connections.
181
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS Constants
182
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_AttributeID
A QTSS_AttributeID is a signed 32-bit integer that uniquely identifies an attribute.
typedef SInt32 QTSS_AttributeID;
QTSS_Object
A QTSS_Object is a pointer to a value that identifies a particular object. The QTSS_Object is defined
as
typedef void* QTSS_Object;
Discussion
The QTSS_Object is used to define other QTSS objects:
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
typedef
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_Object
QTSS_RTPStreamObject;
QTSS_RTSPSessionObject;
QTSS_RTSPRequestObject;
QTSS_RTSPHeaderObject;
QTSS_ClientSessionObject;
QTSS_ConnectedUserObject;
QTSS_ServerObject;
QTSS_PrefsObject;
QTSS_TextMessagesObject;
QTSS_FileObject;
QTSS_ModuleObject;
QTSS_ModulePrefsObject;
QTSS_AttrInfoObject;
QTSS_UserProfileObject;
QTSS_ObjectType
A QTSS_ObjectType is a value of type UInt32 that identifies a particular QTSS object type.
typedef UInt32 QTSS_ObjectType;
Discussion
183
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
qtssAttrInfoObjectType The attribute information object type. Objects of this type have
qtssClientSessionObjectType The client session object type. Objects of this type have
qtssConnectedUsderObjectType The connected user object type. Objects of this type have
qtssFileObjectType The file object type. Objects of this type have attributes that describe an
open file.
qtssModuleObjectType The module object type. Objects of this type have attributes that
qtssModulePrefsObjectType The module preferences object type. Objects of this type have
qtssPrefsObjectType The preferences object type. Objects of this type have attributes that
qtssRTPStreamObjectType The RTPS stream object type. Objects of this type have attributes
qtssRTSPHeaderObjectType The RTSP header object type. Objects of this type have attributes
that contain all of the RTSP headers associated with an individual RTSP request.
qtssRTSPRequestObjectTYPE The RTSP request object type. Objects of this type have attributes
qtssRTSPSessionObjectType The RTSP session object type. Objects of this type have attributes
qtssServerObjectType The server object type. Objects of this type have attributes that contain
qtssTextMessageOjbectType The text messages object type. Objects of this type have attributes
qtssUserProfileObjectType The user profile object type. Objects of this type have attributes
that contain information about a user, such as name, password, the groups the user is a member
of, and the users authentication realm.
QTSS_Role
A value of type QTSS_Role is an unsigned 32-bit integer used to store module roles. It is defined as
typedef UInt32 QTSS_Role;
QTSS_ServiceID
A QTSS_ServiceID is a signed 32-bit integer that uniquely identifies a service. It is defined as
typedef SInt32 QTSS_ServiceID;
184
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
QTSS_StreamRef
A value of type QTSS_StreamRef is a pointer to a value that identifies a particular stream. It is defined
as
typedef void* QTSS_StreamRef;
Discussion
The QTSS_StreamRef is used to define other stream references:
typedef
typedef
typedef
typedef
typedef
typedef
QTSS_StreamRef
QTSS_StreamRef
QTSS_StreamRef
QTSS_StreamRef
QTSS_StreamRef
QTSS_StreamRef
QTSS_ErrorLogStream;
QTSS_FileStream;
QTSS_RTSPSessionStream;
QTSS_RTSPRequestStream;
QTSS_RTPStreamStream;
QTSS_SocketStr
QTSS_TimeVal
A value of type QTSS_TimeVal is a signed 64-bit integer used to store time values. It is defined as
typedef SInt64 QTSS_TimeVal;
185
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R
186
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
R E V I S I O N
H I S T O R Y
This table describes the changes to QuickTime Streaming Server Modules Programming Guide.
Date
Notes
Tiger
Updated for consistency with version 5.0 of the programming interface for creating
QuickTime Streaming Server (QTSS) modules.
187
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
R E V I S I O N
H I S T O R Y
188
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
Index
Q
qtssASFlagsAllowDestination constant 177
qtssASFlagsForceInterleave constant 177
qtssAttrDataTypeBool16 constant 175
qtssAttrDataTypeCharArray constant 175
qtssAttrDataTypeFloat32 constant 176
qtssAttrDataTypeFloat64 constant 176
qtssAttrDataTypeNumTypes constant 176
qtssAttrDataTypeQTSS_Object constant 176
qtssAttrDataTypeQTSS_StreamRef constant 176
qtssAttrDataTypeSInt16 constant 175
qtssAttrDataTypeSInt32 constant 176
qtssAttrDataTypeSInt64 constant 176
qtssAttrDataTypeTimeVal constant 176
qtssAttrDataTypeUInt16 constant 176
qtssAttrDataTypeUInt32 constant 176
qtssAttrDataTypeUnknown constant 175
qtssAttrDataTypeVoidPointer constant 176
qtssAttrModePrempSafe constant 177
qtssAttrModeRead constant 176
qtssAttrModeWrite constant 176
qtssAudioPayloadType constant 179
qtssCliSesTearDownClientRequest constant 177
qtssCliSesTearDownServerInternalErr constant
177
qtssCliSesTearDownServerShutdown constant 177
qtssCliSesTearDownUnsupportedMedia constant
177
qtssFatalErrorState constant 181
qtssIdleState constant 181
qtssOpenFileAsync constant 178
qtssOpenFileNoFlags constant 178
qtssOpenReadAhead constant 178
qtssPausedState constant 179
qtssPlayingState constant 179
qtssRefusingConnectionsState constant 181
qtssRTPNetworkModeDefault constant 179
qtssRTPNetworkModeMulticast constant 179
qtssRTPNetworkModeUnicast constant 179
qtssRTPTransportTypeReliableUDP constant 180
QTSS_AddStreamFlags 177
QTSS_Advis callback 160
QTSS_AppendRTSPHeader callback 168
QTSS_AttrDataType 175
QTSS_AttributeID data type 183
QTSS_AttrPermission 176
QTSS_CliSesTeardownReason 177
QTSS_CloseFileObject callback 166
QTSS_CreateObjectType callback 143
QTSS_CreateObjectValue callback 144
QTSS_Delete callback 142
QTSS_DoService callback 167
QTSS_EventType 178
QTSS_Flush callback 165
QTSS_GetAttrInfoByID callback 148
QTSS_GetAttrInfoByIndex callback 149
QTSS_GetAttrInfoByName callback 149
QTSS_GetNumAttributes callback 150
QTSS_GetValue callback 151
QTSS_GetValueAsString callback 152
QTSS_GetValuePtr callback 153
QTSS_IDForAttr callback 154
QTSS_IDForService callback 167
QTSS_LockObject callback 145
QTSS_Milliseconds callback 143
QTSS_MilliSecsTo1970Secs callback 143
QTSS_New callback 142
189
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.
I N D E X
QTSS_OpenFileFlags 178
QTSS_OpenFileObject callback 165
QTSS_Pause callback 172
QTSS_Play callback 171
QTSS_Read callback 160
QTSS_ReadableEvent constant 178
QTSS_RemoveInstanceAttribute callback 154
QTSS_RemoveValue callback 155
QTSS_RequestEvent callback 162
QTSS_Role data type 184
QTSS_RTPNetworkMode 179
QTSS_RTPPayloadType 178
QTSS_RTPSessionState 179
QTSS_RTPTransportType 180
QTSS_RTSPSessionType 180
QTSS_Seek callback 161
QTSS_SendRTSPHeaders callback 169
QTSS_SendStandardRTSPResponse callback 169
QTSS_ServerState 180
QTSS_ServiceID data type 184
QTSS_SetValue callback 156
QTSS_SetValuePtr callback 156
QTSS_SignalStream callback 162
QTSS_StreamRef data type 185
QTSS_StringToValue callback 157
QTSS_Teardown callback 172
QTSS_TimeVal data type 185
QTSS_TypeStringToType callback 158
QTSS_TypeToTypeString callback 158
QTSS_UnLockObject callback 145
QTSS_ValueToString callback 159
QTSS_Write callback 163
QTSS_WriteableEvent constant 178
QTSS_WriteV callback 164
190
Tiger | 2002, 2005 Apple Computer, Inc. All Rights Reserved.