## Darwin Streaming Server

## Source Code Description

This document provides detailed information on the internals of the Darwin Streaming Server. The server implements four standard IETF protocols, RTSP (Real-time streaming protocol, RFC 2326), RTP (Real-time Transport Protocol, RFC 1889), RTCP (Real-time transport control protocol, RFC 1889), and SDP (Session description protocol, RFC 2327). Before making modifications to the server code is may help to be familiar with those RFCs.

### Introduction

The Darwin 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 code for each of the server's subsystems is separated out into separate folders in the source hierarchy. The following is a short description of each subsytem.

### Common Utilities (in CommonUtilitiesLib)

Common Utilities is a toolkit of thread management, data structure, networking, and text parsing utilities. Darwin Streaming Server and associated tools use these classes to accomplish the following three goals:

- Reduce repeated code by abstracting similar or identical tasks,
- Make the higher level code simpler through encapsulation,
- Separate out any and all platform-specific code.

Here is a short description of all the classes in the Common Utilities subsystem by group:

- OS Classes: Platform-specific code abstractions for timing, condition variables, mutexes, and threads: OS, OSCond, OSMutex, OSThread, OSFileSource. Data structures: OSQueue, OSHashTable, OSHeap, OSRef.
- Sockets: Platform-specific code abstractions for TCP and UDP networking. Socket classes are generally asynchronous (or non-blocking), and can send events to "Task objects". For a complete description on how this works, see "What are task objects?" in the FAQ section. Classes are: EventContext, Socket, UDPSocket, UDPDemuxer, UDPSocketPool, TCPSocket, TCPListenerSocket.
- Parsing Utilities: These classes serve as a toolkit for parsing and formatting text. Classes are: StringParser, StringFormatter, StrPtrLen, StringTranslator.
- Tasks: These classes implement the asynchronous event mechanism the server uses. For a complete description of how tasks work, see "What are task objects?" in the FAQ section. Classes include: Task, TimeoutTask, IdleTask.
- RTCPUtilitiesLib: Classes for encoding and decoding RTCP packets(BR QTFileLib - Simple API for parsing the Hint Track format and generating packets.

### Server Core (in Server.tproj)

This folder contains the core server code, which can be divided into three categories: server core, RTSP specific, and RTP specific.

- RTSP subsystem: These classes handle the parsing & 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 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.

© 1999-2003 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, Mac, Macintosh, PowerBook, Power Macintosh, and QuickTime are trademarks of Apple Computer, Inc., registered in the United States and other countries. iBook, iMac, and Power Mac are trademarks of Apple Computer, Inc. All other product names are trademarks or registered trademarks of their respective holders.