<commit_before>= rtsp

* https://github.com/turboladen/rtsp

{<img src="https://secure.travis-ci.org/turboladen/rtsp.png" alt="Build Status" />}[https://travis-ci.org/turboladen/rtsp]

== DESCRIPTION:

This library intends to follow the RTSP RFC document (2326) to allow for working
with RTSP servers.  By way of {rtp}[https://github.com/turboladen/rtp], you can
either inspect the RTP packets as they come across the wire or use the file
that the data got saved to.

For more information:

* RTSP: {http://tools.ietf.org/html/rfc2326}[http://tools.ietf.org/html/rfc2326]
* RTP: {http://tools.ietf.org/html/rfc3550}[http://tools.ietf.org/html/rfc3550]
* SDP: {http://tools.ietf.org/html/rfc4566}[http://tools.ietf.org/html/rfc4566]

== FEATURES/PROBLEMS:

* All standard RTSP methods supported except REDIRECT.
* Captures RTP data to a file, or yields if a block is passed to #play.
* One client object can only handle 1 stream; use a client per stream until this
  functionality gets implemented.
* Only handles unicast, TCP RTSP communication.
* RTSP exceptions are all {RTSP::Error}s.

== SYNOPSIS:

=== Basic Usage

  RTSP::Client.log?                # => false
  RTSP::Client.log = true
  client = RTSP::Client.new "rtsp://172.16.17.32/sa.sdp"

  client.server_uri                   # => #<URI::Generic:0x00000100ba4db0 URL:rtsp://172.16.17.32:554/sa.sdp>
  client.session_state                # => :init
  client.cseq                         # => 1
  client.connection.do_capture        # => true
  client.connection.interleave        # => false
  client.connection.timeout           # => 30
  client.capturer.ip_addressing_type  # => :unicast
  client.capturer.rtp_port            # => 6970
  client.capturer.capture_file        # => #<File:/var/folders/tg/j9jxvvfs4qn9cg4vztzyy2gc0000gp/T/rtp_capture.raw-59901-1l8dgv2>
  client.capturer.transport_protocol  # => :UDP
  
  response = client.options
  response.class             # => RTSP::Response
  response.code              # => 200
  response.message           # => "OK"
  client.cseq                # => 2
  
  response = client.describe
  response.body.class             # => SDP::Description
  response.content_type           # => "application/sdp"
  response.server                 # => "DSS/5.5 (Build/489.7; Platform/Linux; Release/Darwin; )"
  client.aggregate_control_track  # => "rtsp://172.16.17.32:554/sa.sdp/"
  client.media_control_tracks     # => ["rtsp://172.16.17.32:554/sa.sdp/trackID=1"]
  client.cseq                     # => 3
  
  response = client.setup(client.media_control_tracks.first)
  response.session[:session_id]   # => 7098486223178290313
  client.session[:session_id]     # => 7098486223178290313
  client.cseq                     # => 4
  client.session_state            # => :ready

  response = client.play(client.aggregate_control_track)
  response.range            # => "npt=now="
  resposne.rtp_info         # => "url=rtsp://172.16.17.32:554/sa.sdp/trackID=1"
  client.session_state      # => :playing

  # Wait while the video streams
  sleep 5

  client.pause(client.aggregate_control_track)
  client.session_state    # => :ready

  # Wait while the video is paused
  sleep 2

  client.teardown(client.aggregate_control_track)
  client.session[:session_id]   # => 0
  client.session_state          # => :init

  # Check the streamed file's contents
  puts client.capturer.rtp_file     # => (Lots of data)

=== RTP packet inspection

As of RTP 0.1.0, you can now inspect and use packets as they come across the
wire:

  client = RTSP::Client.new "rtsp://172.16.17.32/sa.sdp"
  client.describe
  client.setup(client.media_control_tracks.first)
  payload_file = File.new('rtp.data', 'wb')

  client.play(client.aggregate_control_track) do |packet|
    puts "packet is a #{packet.class}"
    puts "RTP seqence: #{packet['sequence_number']"
    puts "RTP payload type: #{packet['payload_type']"

    # Let's save the payload data while we're at it...
    payload_file.write(packet['rtp_payload'])
  end

  payload_file.close

Take a look at the {RTP::Packet docs}[http://rdoc.info/gems/rtp/RTP/Packet] for
more information.

=== CLI App<commit_msg>More cleanup<commit_after>= rtsp

* https://github.com/turboladen/rtsp

{<img src="https://secure.travis-ci.org/turboladen/rtsp.png" alt="Build Status" />}[https://travis-ci.org/turboladen/rtsp]

== DESCRIPTION:

This library intends to follow the RTSP RFC document (2326) to allow for working
with RTSP servers.  By way of {rtp}[https://github.com/turboladen/rtp], you can
either inspect the RTP packets as they come across the wire or use the file
that the data got saved to.

For more information:

* RTSP: {http://tools.ietf.org/html/rfc2326}[http://tools.ietf.org/html/rfc2326]
* RTP: {http://tools.ietf.org/html/rfc3550}[http://tools.ietf.org/html/rfc3550]
* SDP: {http://tools.ietf.org/html/rfc4566}[http://tools.ietf.org/html/rfc4566]

== FEATURES/PROBLEMS:

* All standard RTSP methods supported except REDIRECT.
* Captures RTP data to a file, or yields if a block is passed to #play.
* One client object can only handle 1 stream; use a client per stream until this
  functionality gets implemented.
* Only handles unicast, TCP RTSP communication.
* RTSP exceptions are all {RTSP::Error}s.

== SYNOPSIS:

=== Basic Usage

  RTSP::Client.log?                # => false
  RTSP::Client.log = true
  client = RTSP::Client.new "rtsp://172.16.17.32/sa.sdp"

  client.server_uri                   # => #<URI::Generic:0x00000100ba4db0 URL:rtsp://172.16.17.32:554/sa.sdp>
  client.session_state                # => :init
  client.cseq                         # => 1
  client.connection.do_capture        # => true
  client.connection.interleave        # => false
  client.connection.timeout           # => 30
  client.capturer.ip_addressing_type  # => :unicast
  client.capturer.rtp_port            # => 6970
  client.capturer.capture_file        # => #<File:/var/folders/tg/j9jxvvfs4qn9cg4vztzyy2gc0000gp/T/rtp_capture.raw-59901-1l8dgv2>
  client.capturer.transport_protocol  # => :UDP
  
  response = client.options
  response.class             # => RTSP::Response
  response.code              # => 200
  response.message           # => "OK"
  client.cseq                # => 2
  
  response = client.describe
  response.body.class             # => SDP::Description
  response.content_type           # => "application/sdp"
  response.server                 # => "DSS/5.5 (Build/489.7; Platform/Linux; Release/Darwin; )"
  client.aggregate_control_track  # => "rtsp://172.16.17.32:554/sa.sdp/"
  client.media_control_tracks     # => ["rtsp://172.16.17.32:554/sa.sdp/trackID=1"]
  client.cseq                     # => 3
  
  response = client.setup(client.media_control_tracks.first)
  response.session[:session_id]   # => 7098486223178290313
  client.session[:session_id]     # => 7098486223178290313
  client.cseq                     # => 4
  client.session_state            # => :ready

  response = client.play(client.aggregate_control_track)
  response.range            # => "npt=now="
  resposne.rtp_info         # => "url=rtsp://172.16.17.32:554/sa.sdp/trackID=1"
  client.session_state      # => :playing

  # Wait while the video streams
  sleep 5

  client.pause(client.aggregate_control_track)
  client.session_state    # => :ready

  # Wait while the video is paused
  sleep 2

  client.teardown(client.aggregate_control_track)
  client.session[:session_id]   # => 0
  client.session_state          # => :init

  # Check the streamed file's contents
  puts client.capturer.capture_file     # => (Lots of data)

=== RTP packet inspection

As of RTP 0.1.0, you can now inspect and use packets as they come across the
wire:

  client = RTSP::Client.new "rtsp://172.16.17.32/sa.sdp"
  client.describe
  client.setup(client.media_control_tracks.first)
  payload_file = File.new('rtp.data', 'wb')

  client.play(client.aggregate_control_track) do |packet|
    puts "packet is a #{packet.class}"
    puts "RTP seqence: #{packet.sequence_number}"
    puts "RTP payload type: #{packet.payload_type}"

    # Let's save the payload data while we're at it...
    payload_file.write(packet.rtp_payload)
  end

  payload_file.close

Take a look at the {RTP::Packet docs}[http://rdoc.info/gems/rtp/RTP/Packet] for
more information.

=== CLI App
{'fraction_non_alphanumeric': 0.13070238957277336, 'fraction_numerical': 0.045377745594979486, 'mean_word_length': 2.8924377642085486, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 73, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1394940', 'n_tokens_mistral': 3115, 'n_tokens_neox': 2808, 'n_words': 584}