[MPlayer-dev-eng] [PATCH] Network synchronized playback using UDP

Jason Holt jholt at google.com
Tue May 19 01:08:45 CEST 2009


On Sat, Apr 11, 2009 at 6:34 AM, Diego Biurrun <diego at biurrun.de> wrote:

> You could create new source files, that sounds sensible.


Done.


> > --- DOCS/xml/en/usage.xml     (revision 29167)
> > +++ DOCS/xml/en/usage.xml     (working copy)
> > @@ -494,6 +494,74 @@
> > +
> > +<para>
> > +If <option>-udp-master</option> is given,
> <application>MPlayer</application>
> > +sends a datagram to <option>-udp-ip</option> (default: 127.0.0.1)
> > +on <option>-udp-port</option> (default: 23867) just before playing each
> frame.
> > +The datagram indicates the master's position in the file. If
> > +<option>-udp-slave</option> is given, <application>MPlayer</application>
> listens on
> > +<option>-udp-ip</option>/<option>-udp-port</option>
> > +and matches the master's position. Setting <option>-udp-ip</option> to
> the
> > +master's broadcast address allows multiple slaves having the same
> broadcast
> > +address to sync to the master.
> > +</para>
>
> This sounds as if -udp-ip and -udp-port are required, are they?


No, but usually people won't be running mplayer instances on the same
machine, so they'll want to supply a different IP (and perhaps port).



> > +<para>
> > +<option>-udp-seek-threshold</option> (default: 1) should probably be
> left
> > +at its default setting. When the master seeks, the slave has to decide
> > +whether to seek as well, or to catch up by decoding frames without
> pausing
> > +between frames. If the master is more than
> > +<option>-udp-seek-threshold</option> seconds away from the slave, the
> slave
> > +seeks. Otherwise, it "runs" to catch up or waits for the master.
> > +</para>
>
> Maybe this could be placed after the example since it is advanced usage.
> But the description should not duplicate the content of the man page.
> Just talk about possible use cases for the option.


Removed.


> > +<para>
> > +On each slave, run:
> > +</para>
> > +
> > +<screen>
> > +mplayer -udp-slave videoN.mpg
> > +</screen>
>
> Why 'N'?


N is a traditional metavariable for natural numbers.  If you have 3 slaves,
they'd presumably be playing video2.mpg through video4.mpg while the master
plays video1.mpg.



> > --- DOCS/man/en/mplayer.1     (revision 29167)
> > +++ DOCS/man/en/mplayer.1     (working copy)
> > @@ -1149,8 +1149,36 @@
> >  .
> > +.TP
> > +.B \-udp\-seek\-threshold <sec>
> > +This should probably be left at its default setting of 1 second.
>
> That's a very vague statement and if at all, it should come after the
> description of the option.


Removed.


> > --- mplayer.c (revision 29167)
> > +++ mplayer.c (working copy)
> > @@ -743,6 +766,163 @@
> >
> > +    sockfd=socket(AF_INET,SOCK_DGRAM,0);
>
> extra good karma for spaces around the '='.
>
> > +    memset(&servaddr,sizeof(servaddr), 0);
> > +    servaddr.sin_family = AF_INET;
> > +    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
> > +    servaddr.sin_port=htons(udp_port);
>
> align


Done.


> +  if (blocking) {
> > +    fcntl(sockfd, F_SETFL, sock_flags & (~O_NONBLOCK));
> > +  } else {
> > +    fcntl(sockfd, F_SETFL, sock_flags | O_NONBLOCK);
> > +  }
>
> pointless {}


Unnecessary, but I wouldn't say pointless.


> +  n = recvfrom(sockfd,mesg,999,0,(struct sockaddr *)&cliaddr,&len);
>
> extra good karma for spaces around the ','.


Done.


> +    if ((my_position > udp_master_position - udp_seek_threshold) &&
> > +        (my_position < udp_master_position + udp_timing_tolerance)) {
> > +      closebehind = 1;
> > +    } else {
> > +      closebehind = 0;
> > +    }
>
> pointless {}


Simile.

(Also, updated per Uoti's recommendation.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayer-udp-patch-11.diff
Type: text/x-diff
Size: 14296 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20090518/b61d7802/attachment.diff>


More information about the MPlayer-dev-eng mailing list