Posted on 2003-03-04
Medium Priority
Last Modified: 2008-02-01

Want to implement a very basic RTP stream in PHP:

The RTP information for the stream:

    * The codec specifies G.711 mu-Law.
    * The packet size specifies 20 ms.

Basically, i would have a wav or au file in the above codec, i want to make php send this info as an rtp stream to a specific IP (which is set to recieve) on port 20002

I'm thinking something like:

header("Content-type: audio/mp3\n");
header("Content-Disposition: attachment; filename=".$file."\n");
header("Content-length: ".filesize($filename)."\n");
$fp = fopen($filename, 'rb');
while(!feof($fp)) {
  print fread($fp, 4096); }

Where audio/mp3 would be replaced with something more appropriate and i would call the script like rtsp://domain/test.php.

I have no idea where to start or if RTSP even accepts headers, or how to make php broadcast on port 20002.

Any reasonable insight would be rewarded.
Question by:conner_bw
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 15

Accepted Solution

VGR earned 400 total points
ID: 8070274
to send data on port 20002, it's easy : fsockopen()
the correct MIME-Type has indeed to be specified
The rest should work.
You can also turn magic_quoting off while reading the binary raw data :   set_magic_quotes_runtime(0);

I would also suggets reading all the raw data, not as a text file with buffer of length 4096, but in a big block of data with file()
Then send it via fopen(specificIP:20002), fput or fputs, fclose()

Author Comment

ID: 8105429
This is much harder than i had orriginally anticipated. The answer was a good starting point, but does not help me make my own PHP RTSP "server"

For followups, anyone know of a PHP RSTP (RTP) server solution? All i can find are C and Java ones.

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question