Subject: [MMUSIC] RTSP state machine

From: Magnus Westerlund <[email-masked]>
Date: Wed, 20 Feb 2002 19:56:44 +0100

Hi again!

I made some errors in the table and I guess there may be some more still
in there. Anyway, here is a new version.

RTSP state machine ver. 0.2

This state machine does not contain RECORD which needs to be added.
It is based on the proposal that in aggregated control, PAUSE and PLAY
can't be used on individual medias. If that is allowed there will be
a number of extra transitions with requirements on the
different medias state. Does not include queued play either.

There is discussion if teardown on media URL should end up in a middle
state between Init and Ready-na. This state would contain no media but
keep all session related state and keep its ID. The only way to remove
such a state will be the teardown with * or a session timeout.

States          Explanation
-----------------------------------------------------------------------
Init            Initial state no session exist
Ready-na        Non aggregated session in Ready state
Playing-na      Non aggregated session in Playing state
Paused-na       Non aggregated session in Paused state
Ready-a         Aggregated session in Ready state
Playing-a       Aggregated session in Playing
Paused-a        Aggregated session in Pause

The reason for separating aggregated and non aggregated states are the
following:
- Play and Pause may only be done on aggregate URL and not media URLs
  in aggregated control. In non-aggregated the two are the same.
-

State variables
---------------
Nr-media

State: Init
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
SETUP                           Ready-na        Nr-media = 1

State: Ready-na
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
SETUP           New URL         Ready-a         Nr-media = 2
SETUP           Present URL     Ready-na        Change transport param.
Teardown        *|media URL     Init            Ok
PLAY            No range        Playing-na      from beginning of media
PLAY            Range           Playing-na      according to range
Timeout                         Init

State: Playing-na
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PAUSE           No range        Paused-na       Set pause point
PAUSE           Range > now     Playing-na      Set pause point
Pause-point reached             Paused-na
End of media                    Ready-na
Timeout                         Init
SETUP          New URL,Allowed? Playing-a       Nr-media +=1
SETUP     Present URL, Allowed? Playing-na      Change transport param.
TEARDOWN        Allowed?        Init

State: Paused-na
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PLAY            No range        Playing-na      Play from pause point
PLAY            Range           Playing-na      according to range
Timeout                         Init
SETUP           New URL         Paused-a        Nr-media +=1
SETUP           Present URL     Ready-na        Change transport param.
TEARDOWN        *|media URL     Init

State: Ready-a
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
SETUP           New URL         Ready-a         Nr-media +=1
SETUP          Present mediaURL Ready-a         Change transport param.
TEARDOWN        * | Pres URL    Init            No session hdr.
TEARDOWN        Nr-media >2     Ready-a         Nr-media -=1, sess hdr
TEARDOWN        Nr-media == 2   Ready-na        Nr-media = 1, sess hdr
Timeout                         Init
PLAY            No range,AggURL Playing-a       from beginning of media
PLAY            Range, Agg URL  Playing-a       according to range

State: Playing-a
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PAUSE           No range        Paused-a        Set pause point
PAUSE           Range > now     Playing-a       Set point to pause at
Pause-point reached             Paused-a        Set pause point
End of media    >=1 Media plays Playing-a
End of media    All media ended Ready-a
Timeout                         Init
SETUP          New URL,Allowed? Playing-a       Nr-media +=1
SETUP      Present URL,Allowed? Playing-a       Change transport param
TEARDOWN        *|pres URL      Init            No session hdr allowed?
TEARDOWN        Allowed? Nr-m>2 Playing-a       Nr-media -=1, sess hdr
TEARDOWN        Allowed? Nr-m=2 Playing-na      Nr-media = 1, sess hdr

State: Paused-a
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PLAY            No range        Playing-a       Play from pause point
PLAY            Range           Playing-a       according to range
Timeout                         Init
SETUP           New URL         Paused-a        Nr-media +=1
SETUP           Present URL     Paused-a        Change transport param.
TEARDOWN        *|pres URL      Init
TEARDOWN        Nr-media >2     Paused-a        Nr-media -=1
TEARDOWN        Nr-media == 2   Paused-na       Nr-media = 1

Cheers

Magnus Westerlund

Multimedia Technologies, Ericsson Research ERA/T/VA
----------------------------------------------------------------------
Ericsson Radio Systems AB  | Phone +46 8 4048287
Torshamsgatan 23           | Fax   +46 8 7575550
S-164 80 Stockholm, Sweden | mailto: [email-masked]

_______________________________________________
mmusic mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/mmusic

---

From: Rob Lanphier <[email-masked]>
Date: Tue, 26 Feb 2002 16:56:49 -0800 (Pacific Standard Time)

Hi Magnus,

This is really good work.  Still sifting through the implications here,
but one quick question to kick off the conversation:  could the "ready-na"
state and "paused-na" state be merged (as well as "ready-a" and
"paused-a")?  I'm not sure there's a useful distinction to be made between
these two states.

Rob

---

From: Magnus Westerlund <[email-masked]>
Date: Wed, 27 Feb 2002 10:47:50 +0100

Rob,

In my opinion they have a useful distinction. The different state represent if
the point of pausing is valid or not. This is part of the state and it helps
clarify behavior regarding pause and play without range. When in ready-na and
receiving a play without range it changes state to playing-na and plays from
the beginning. When in pause-na and receives the same play it will play from
the pause point stored upon entering the pause state.

We have had a discussion on this during one of the telecoms. What was raised
then was the following. When a play without range is issued in state ready-na
it starts from the beginning. When the server reaches the end of the media,
what shall it do. My interpretation which is represented in the state machine
is that it returns to ready-na, when doing play without range again it will
start from the beginning. Another interpretation is that it stays at the end
point and any play without range will be accepted but return to ready state
directly as it is at the end. This behavior requires a explicit rewind of the
media with a play with range 0- to start from the beginning.

This is logged as issue #513875 at source forge.

Regards

Magnus

--

Magnus Westerlund

---

From: Tom Marshall <[email-masked]>
Date: Wed, 27 Feb 2002 12:09:47 -0800

> the pause point stored upon entering the pause state.

I don't see the distinction.  After a successful setup, is the clip not
paused at time zero?

> media with a play with range 0- to start from the beginning.

I don't like the idea of the server rewinding the clip without being
requested by the client.

I would prefer that the end-of-clip functionality match the rest of the
protocol, in that the client initiates all of the server's state
transitions.  When the server reaches the end of the clip, why can't it stay
in the playing state until the client sends a pause or teardown?

If the server makes the state transition on its own, the client runs the
possibility that a pause message very close to the end of the clip could
reach the server after the clip has finished and the server is back in the
ready/paused state.  The expected behaviour doesn't seem to be defined in
this case, for either the old or the proposed state machine.

---

From: Jonathan Sergent <[email-masked]>
Date: Wed, 27 Feb 2002 17:02:07 -0800

> this case, for either the old or the proposed state machine.

Thank you for agreeing with me (I have pointed this out before but not
really gotten anyone to think it is as ugly as I do).  This has
actually turned up as a bug for us, because we used to refuse PAUSE
while paused.

The other way around this is to let the server transition in state but
to make sure that requests received close to the end of the stream have
the same effect as requests received immediately after the end of the
stream.  Using PLAY with no range header as a "ping" makes this not
true.

I think the cleanest thing is what you suggest, that the client should
need to send a PAUSE if it expects the server to be in the paused
state.

---

From: Jonathan Sergent <[email-masked]>
Date: Wed, 27 Feb 2002 17:04:37 -0800

> media with a play with range 0- to start from the beginning.

A more interesting case to look at is if the initial PLAY request has a
closed range in the Range header (i.e. Range: npt=0-15).  After playing
has stopped due to the closed range, the client sends a PLAY with no
range header.  Does the stream restart from the beginning, or from
npt=15?

--jss.

---

From: Magnus Westerlund <[email-masked]>
Date: Thu, 28 Feb 2002 17:51:04 +0100

Hi Rob, Tom and Jonathan,

I have reconsidered about removing pause state and I can agree that it is
unnecessary. I attach an updated version of the state machine without the paused
state. Instead I replaced it with setting of the pause point or as I have called it
in the state machine resume point (RP). I think that is a better name for it.

I do believe we have the following  issues regarding pause, play and reaching end
of media or range.

- When a presentation reaches end of media or range. Shall it automatically return
to ready state?

- When a presentation reaches end of media. What shall the resume point be set to?

- When reaching end of a range, should the resume point be set to 0 or end of
range?

- Should we add a end of clip/range notification.

I will start with the last issue. I do believe such a mechanism is need for more
than this reason to signal the state transition. It will also be good for the
buffer handling, retransmission, adaptation, and notification to user. So I do
agree that we should add one

Then I do believe you are suggesting a control model like a old tape player, I have
always thought of it in terms of CD player control. All my CD players return to the
beginning of the disc when reaching end. But one thing we really do need to
consider is backwards compatibility. Will an RFC 2326 implemented client be able to
use a server that would requires a pause before each play after the first? I would
guess that it would get into trouble. Also how should this work relative to queued
play? Even if we remove as suggested I belive it will be difficult to combine this
model with that. Therefore I would like to have automatic return to state READY.

I think that the resume point should be reset to 0.0 when reaching end of media.
Actually I don't care that much about this behavior except that it should be
backwards compatible. If it does not return without a explicit play 0- can this
break any client?

Regarding reaching end of range I have no strong opinion on what to do as long as
it is resolved. The state machine says to set it to 0.0 for moment which is
harmonized with end of media behavior.

By removing play without range while playing and also queued plays we remove the
functionality that has potentials for messing up at end of streams.

Regards

Magnus Westerlund

RTSP state machine ver. 0.3

I now have removed the paused state.

States          Explanation

State variables
---------------
Nr-media	 The number of medias currently setuped in this session
RP = Resume point  The point that a play request without range resumes.

State: Init
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
SETUP                           Ready-na        Nr-media = 1, RP=0.0

State: Ready-na
PLAY            No range        Playing-na      Play from RP

State: Playing-na
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PAUSE           No range        Ready-na       Set RP to present point
PAUSE           Range > now     Playing-na      Set RP to given point 
Pause-point reached             Ready-na	
End of media                    Ready-na	Set RP = 0.0
End of range			Ready-na	Set RP = 0.0?
Timeout                         Init
SETUP          New URL,Allowed? Playing-a       Nr-media +=1
SETUP     Present URL, Allowed? Playing-na      Change transport param.
TEARDOWN        Allowed?        Init    

State: Ready-a  
PLAY            No range,AggURL Playing-a       From RP

State: Playing-a
Action          Prerequisite    New State       Response
-----------------------------------------------------------------------
PAUSE           No range        Ready-a        Set RP to present pos.
PAUSE           Range > now     Playing-a       Set RP to given point 
Pause-point reached             Ready-a        
End of range			Ready-a		Set RP = 0.0?
End of media    >=1 Media plays Playing-a	
End of media    All media ended Ready-a		Set RP to 0.0
Timeout                         Init
SETUP          New URL,Allowed? Playing-a       Nr-media +=1
SETUP      Present URL,Allowed? Playing-a       Change transport param
TEARDOWN        *|pres URL      Init            No session hdr allowed?
TEARDOWN        Allowed? Nr-m>2 Playing-a       Nr-media -=1, sess hdr
TEARDOWN        Allowed? Nr-m=2 Playing-na      Nr-media = 1, sess hdr

---

From: Magnus Westerlund <[email-masked]>
Date: Thu, 28 Feb 2002 18:03:34 +0100

Hi,

I have directly answered your questions despite the fact that they are present in my
other email today.

> in the playing state until the client sends a pause or teardown?

The biggest problem I have with this is backwards compatibility. The proposed
behavior requires that you pipeline all play request with a pause the plat to change
to ready state. And I don't believe all clients out there has this behavior.

> this case, for either the old or the proposed state machine.

In the new state machine there is no need. Doing play without range will be
decapricated due to the fact that it could cause restarting of stream. If we also
remove queued plays the client will receive a error message "not allowed in this
state" if the is in playing state.

Cheers

Magnus Westerlund