sdp 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/ChangeLog.rdoc +13 -0
  2. data/LICENSE.rdoc +1 -1
  3. data/README.rdoc +31 -11
  4. data/Rakefile +3 -10
  5. data/lib/sdp/description.rb +132 -16
  6. data/lib/sdp/parser.rb +4 -4
  7. data/lib/sdp/version.rb +1 -1
  8. data/sdp.gemspec +15 -15
  9. data/spec/integration/builds_descriptions_spec.rb +39 -0
  10. data/spec/integration/coverage/assets/0.7.1/application.css +1110 -0
  11. data/spec/integration/coverage/assets/0.7.1/application.js +626 -0
  12. data/spec/integration/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  13. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  14. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  15. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  16. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  17. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  18. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  19. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  20. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  21. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  22. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  23. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  24. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  25. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  26. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  27. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  28. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  29. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  30. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  31. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  32. data/spec/integration/coverage/assets/0.7.1/favicon_green.png +0 -0
  33. data/spec/integration/coverage/assets/0.7.1/favicon_red.png +0 -0
  34. data/spec/integration/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  35. data/spec/integration/coverage/assets/0.7.1/loading.gif +0 -0
  36. data/spec/integration/coverage/assets/0.7.1/magnify.png +0 -0
  37. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  38. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  39. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  40. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  41. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  42. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  43. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  44. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  45. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  46. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  47. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  48. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  49. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  50. data/spec/integration/coverage/index.html +72 -0
  51. data/spec/integration/parses_descriptions_spec.rb +129 -0
  52. data/spec/spec_helper.rb +2 -1
  53. data/spec/support/parser_matcher.rb +33 -0
  54. data/{features → spec}/support/sdp_file.txt +0 -0
  55. data/spec/support/test_descriptions.rb +137 -0
  56. data/spec/unit/sdp/coverage/assets/0.7.1/application.css +1110 -0
  57. data/spec/unit/sdp/coverage/assets/0.7.1/application.js +626 -0
  58. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  59. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  60. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  61. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  62. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  63. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  64. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  65. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  66. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  67. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  68. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  69. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  70. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  71. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  72. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  73. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  74. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  75. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  76. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  77. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  78. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_green.png +0 -0
  79. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_red.png +0 -0
  80. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  81. data/spec/unit/sdp/coverage/assets/0.7.1/loading.gif +0 -0
  82. data/spec/unit/sdp/coverage/assets/0.7.1/magnify.png +0 -0
  83. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  84. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  85. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  86. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  87. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  88. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  89. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  90. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  91. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  92. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  93. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  94. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  95. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  96. data/spec/unit/sdp/coverage/index.html +72 -0
  97. data/spec/unit/sdp/description_spec.rb +321 -0
  98. data/spec/unit/sdp/parser_spec.rb +154 -0
  99. data/spec/{sdp_spec.rb → unit/sdp_spec.rb} +2 -2
  100. metadata +189 -43
  101. data/features/accepts_description_text.feature +0 -12
  102. data/features/sdp_create.feature +0 -15
  103. data/features/sdp_get.feature +0 -37
  104. data/features/step_definitions/accepts_description_text_steps.rb +0 -15
  105. data/features/step_definitions/sdp_create_steps.rb +0 -48
  106. data/features/step_definitions/sdp_get_steps.rb +0 -23
  107. data/features/support/env.rb +0 -3
  108. data/lib/sdp/session_template.erb +0 -46
  109. data/spec/sdp/description_spec.rb +0 -392
  110. data/spec/sdp/parser_spec.rb +0 -207
@@ -1,12 +0,0 @@
1
- Feature: Accept description as a String
2
- As an SDP user
3
- I want to be able to parse a String of an SDP description
4
- (that I received from a server, perhaps) and turn it into Ruby
5
- objects
6
- So that I can more easily work with each piece of the description
7
-
8
- Scenario: Description without time zone fields
9
- Given a description with no time zone fields
10
- When I parse the description
11
- Then I can access the protocol_version field value
12
- And put the description back to a String
@@ -1,15 +0,0 @@
1
- Feature: Programmatically create an SDP file
2
- As a utility using SDP to describe a multimedia session
3
- I want to be able to turn Ruby code in to an SDP description,
4
- as specified in RFC 4566
5
- So that I can use Ruby to describe the multimedia session
6
-
7
- Scenario: Create an SDP file from a Ruby object
8
- Given I know what the SDP file should look like
9
- When I build the Ruby object with the appropriate fields
10
- Then the resulting file should look like the intended description
11
-
12
- Scenario: Create a basic SDP object
13
- Given I create an SDP object with no parameters
14
- When I convert it to a String
15
- Then it should have :version set to 0
@@ -1,37 +0,0 @@
1
- Feature: Get SDP file fields and marshall into Ruby data types
2
- As an RTSP consumer
3
- I want to be able to be able to read SDP files into Ruby data types
4
- So that it's easy to determine how to work with the RTSP stream
5
-
6
- Scenario: Parse the RFC 4566 example
7
- Given the RFC 4566 SDP example in a file
8
- When I parse the file
9
- Then the <value> for <field> is accessible via the SDP object
10
- | field | value |
11
- | protocol_version | 0 |
12
- | username | jdoe |
13
- | id | 2890844526 |
14
- | version | 2890842807 |
15
- | network_type | IN |
16
- | address_type | IP4 |
17
- | unicast_address | 10.47.16.5 |
18
- | name | SDP Seminar |
19
- | information | A Seminar on the session description protocol |
20
- | uri | http://www.example.com/seminars/sdp.pdf |
21
- | email_address | j.doe@example.com (Jane Doe) |
22
- | connection_network_type | IN |
23
- | connection_address_type | IP4 |
24
- | connection_address | 224.2.17.12/127 |
25
- | start_time | 2873397496 |
26
- | stop_time | 2873404696 |
27
- | attributes | recvonly |
28
- # | m[0][1] | 49170 |
29
- # | m[0][2] | "RTP/AVP" |
30
- # | m[0][3] | 0 |
31
- # | m[1][1] | 51372 |
32
- # | m[1][2] | "RTP/AVP" |
33
- # | m[1][3] | 99 |
34
- # | a[1][1] | 99 |
35
- # | a[1][2] | "h263-1998" |
36
- # | a[1][3] | 90000 |
37
-
@@ -1,15 +0,0 @@
1
- Given /^a description with no time zone fields$/ do
2
- @sdp_missing_time = "v=0\r\no=- 1809368942 3379601213 IN IP4 127.0.0.1\r\ns=Secret Agent from SomaFM\r\ni=Downtempo Spy Lounge\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\na=x-qt-text-cmt:Orban Opticodec-PCx-qt-text-nam:Secret Agent from SomaFMx-qt-text-inf:Downtempo Spy Loungecontrol:*\r\nm=audio 0 RTP/AVP 96\r\na=rtpmap:96 MP4A-LATM/44100/2a=fmtp:96 cpresent=0;config=400027200000a=control:trackID=1\r\n"
3
- end
4
-
5
- When /^I parse the description$/ do
6
- @sdp = SDP.parse @sdp_missing_time
7
- end
8
-
9
- Then /^I can access the protocol_version field value$/ do
10
- @sdp.protocol_version.should == "0"
11
- end
12
-
13
- Then /^put the description back to a String$/ do
14
- @sdp.to_s.should == @sdp_missing_time
15
- end
@@ -1,48 +0,0 @@
1
- require 'sdp/description'
2
-
3
- Given /^I know what the SDP file should look like$/ do
4
- @example_sdp_file = File.read(File.dirname(__FILE__) + "/../support/sdp_file.txt")
5
- end
6
-
7
- When /^I build the Ruby object with the appropriate fields$/ do
8
- @session = SDP::Description.new
9
- @session.protocol_version = 0
10
- @session.username = "jdoe"
11
- @session.id = 2890844526
12
- @session.version = 2890842807
13
- @session.network_type = :IN
14
- @session.address_type = :IP4
15
- @session.unicast_address = "10.47.16.5"
16
- @session.name = "SDP Seminar"
17
- @session.information = "A Seminar on the session description protocol"
18
- @session.uri = "http://www.example.com/seminars/sdp.pdf"
19
- @session.email_address = "j.doe@example.com (Jane Doe)"
20
- @session.connection_network_type = "IN"
21
- @session.connection_address_type = "IP4"
22
- @session.connection_address = "224.2.17.12/127"
23
- @session.start_time = 2873397496
24
- @session.stop_time = 2873404696
25
- @session.attributes << { :attribute => "recvonly" }
26
- @session.media_sections <<
27
- { :media => "audio", :port => 49170, :protocol => "RTP/AVP", :format => 0 }
28
- @session.media_sections <<
29
- { :media => "video", :port => 51372, :protocol => "RTP/AVP", :format => 99,
30
- :attributes => [{ :attribute => "rtpmap", :value => "99 h263-1998/90000" }]
31
- }
32
- end
33
-
34
- Then /^the resulting file should look like the intended description$/ do
35
- @session.to_s.should == @example_sdp_file
36
- end
37
-
38
- Given /^I create an SDP object with no parameters$/ do
39
- @session = SDP::Description.new
40
- end
41
-
42
- When /^I convert it to a String$/ do
43
- @sdp_string = @session.to_s
44
- end
45
-
46
- Then /^it should have :version set to (\d+)$/ do |value|
47
- @sdp_string.should match /v=#{value}/
48
- end
@@ -1,23 +0,0 @@
1
- Given /^the RFC 4566 SDP example in a file$/ do
2
- @sdp_file = File.open(File.dirname(__FILE__) + '/../support/sdp_file.txt', 'r').read
3
- end
4
-
5
- When /^I parse the file$/ do
6
- @sdp = SDP.parse @sdp_file
7
- end
8
-
9
- Then /^the <value> for <field> is accessible via the SDP object$/ do |table|
10
- # table is a Cucumber::Ast::Table
11
- table.hashes.each do |sdp_field|
12
- field_type = sdp_field["field"].to_sym
13
- value = sdp_field["value"]
14
-
15
- actual_value = @sdp.send(field_type)
16
-
17
- if field_type == :attributes
18
- actual_value.first[:attribute].should == value
19
- else
20
- actual_value.to_s.should == value
21
- end
22
- end
23
- end
@@ -1,3 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
- require 'sdp'
3
- require 'sdp/description'
@@ -1,46 +0,0 @@
1
- <%# -*- coding: UTF-8 -*- %>
2
- v=<%= protocol_version %>
3
- o=<%= username %> <%= id %> <%= version %> <%= network_type %> <%= address_type %> <%= unicast_address %>
4
- s=<%= name %>
5
- <% if information %>
6
- i=<%= information %>
7
- <% end %>
8
- <% if uri %>
9
- u=<%= uri %>
10
- <% end %>
11
- <% if email_address %>
12
- e=<%= email_address %>
13
- <% end %>
14
- <% if phone_number %>
15
- p=<%= phone_number %>
16
- <% end %>
17
- <% if connection_network_type %>
18
- c=<%= connection_network_type %> <%= connection_address_type %> <%= connection_address %>
19
- <% end %>
20
- <% if bandwidth %>
21
- b=<%= bandwidth_type %>:<%= bandwidth %>
22
- <% end %>
23
- t=<%= start_time %> <%= stop_time %>
24
- <% if repeat_interval %>
25
- r=<%= repeat_interval %> <%= active_duration %> <%= offsets_from_start_time %>
26
- <% end %>
27
- <% unless time_zones.nil? || time_zones.empty? %>
28
- <% if time_zones.class == Array %>
29
- z=<% time_zones.each do |time_zone| %><%= time_zone[:adjustment_time] %> <%= time_zone[:offset] %><% end %>
30
- <% else %>
31
- z=<%= time_zones[:adjustment_time] %> <%= time_zones[:offset] %><% end %>
32
- <% end %>
33
- <% if encryption_method %>
34
- k=<%= encryption_method %><% if encryption_key %>:<%= encryption_key %><% end %>
35
- <% end %>
36
- <% unless attributes.empty? %>
37
- <% attributes.each do |a| %>
38
- a=<%= a[:attribute] %><% if a[:value] %>:<%= a[:value] %><% end %>
39
- <% end %>
40
- <% end %>
41
- <% media_sections.each do |media_section| %>
42
- m=<%= media_section[:media] %> <%= media_section[:port]%> <%= media_section[:protocol]%> <%= media_section[:format]%>
43
- <% if media_section[:attributes] %>
44
- <% media_section[:attributes].each do |attribute| %>
45
- a=<%= attribute[:attribute] %><% if attribute[:value] %>:<%= attribute[:value] %>
46
- <% end %><% end %><% end %><% end %>
@@ -1,392 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'sdp'
3
- require 'sdp/description'
4
- require 'base64'
5
-
6
- describe SDP::Description do
7
- before :each do
8
- @sdp = SDP::Description.new
9
- end
10
-
11
- it "initializes with the protocol_version value set" do
12
- @sdp.protocol_version.should == SDP::PROTOCOL_VERSION
13
- end
14
-
15
- context "can add and retrieve fields" do
16
- it "protocol_version" do
17
- @sdp.protocol_version = 1
18
- @sdp.protocol_version.should == 1
19
- end
20
-
21
- it "username" do
22
- @sdp.username = "jdoe"
23
- @sdp.username.should == "jdoe"
24
- end
25
-
26
- it "id" do
27
- @sdp.id = 2890844526
28
- @sdp.id.should == 2890844526
29
- end
30
-
31
- it "version" do
32
- @sdp.version = 2890842807
33
- @sdp.version.should == 2890842807
34
- end
35
-
36
- it "network_type" do
37
- @sdp.network_type = :IN
38
- @sdp.network_type.should == :IN
39
- end
40
-
41
- it "address_type" do
42
- @sdp.address_type = :IP4
43
- @sdp.address_type.should == :IP4
44
- end
45
-
46
- it "unicast_address" do
47
- @sdp.unicast_address = "10.47.16.5"
48
- @sdp.unicast_address.should == "10.47.16.5"
49
- end
50
-
51
- it "name" do
52
- @sdp.name = "This is a session"
53
- @sdp.name.should == "This is a session"
54
- end
55
-
56
- it "name can be a ' '" do
57
- @sdp.name = " "
58
- @sdp.name.should == " "
59
- end
60
-
61
- it "information" do
62
- @sdp.information = "This is a session"
63
- @sdp.information.should == "This is a session"
64
- end
65
-
66
- it "uri" do
67
- @sdp.uri = "http://localhost"
68
- @sdp.uri.should == "http://localhost"
69
- end
70
-
71
- it "email_address" do
72
- @sdp.email_address = 'me@me.com'
73
- @sdp.email_address.should == 'me@me.com'
74
- end
75
-
76
- it "email_address in alternate form" do
77
- @sdp.email_address = "Jane Doe <j.doe@example.com>"
78
- @sdp.email_address.should == "Jane Doe <j.doe@example.com>"
79
- end
80
-
81
- it "phone_number" do
82
- @sdp.phone_number = "+1 555 123 4567"
83
- @sdp.phone_number.should == "+1 555 123 4567"
84
- end
85
-
86
- it "connection_network_type" do
87
- @sdp.connection_network_type = 'IN'
88
- @sdp.connection_network_type.should == 'IN'
89
- end
90
-
91
- it "connection_address_type" do
92
- @sdp.connection_address_type = 'IP4'
93
- @sdp.connection_address_type.should == 'IP4'
94
- end
95
-
96
- it "connection_address" do
97
- @sdp.connection_address = 'localhost'
98
- @sdp.connection_address.should == 'localhost'
99
- end
100
-
101
- it "connection_address using TTL" do
102
- @sdp.connection_address = "224.2.36.42/127"
103
- @sdp.connection_address.should == "224.2.36.42/127"
104
- end
105
-
106
- it "connection_address using IPv6 address and count" do
107
- @sdp.connection_address = "FF15::101/3"
108
- @sdp.connection_address.should == "FF15::101/3"
109
- end
110
-
111
- it "bandwidth_type" do
112
- @sdp.bandwidth = :CT
113
- @sdp.bandwidth.should == :CT
114
- end
115
-
116
- it "bandwidth" do
117
- @sdp.bandwidth = 100
118
- @sdp.bandwidth.should == 100
119
- end
120
-
121
- it "start_time" do
122
- @sdp.start_time = 99112299
123
- @sdp.start_time.should == 99112299
124
- end
125
-
126
- it "stop_time" do
127
- @sdp.stop_time = 99999999
128
- @sdp.stop_time.should == 99999999
129
- end
130
-
131
- it "repeat_interval" do
132
- @sdp.repeat_interval = 12345
133
- @sdp.repeat_interval.should == 12345
134
- end
135
-
136
- it "active_duration" do
137
- @sdp.active_duration = 12345
138
- @sdp.active_duration.should == 12345
139
- end
140
-
141
- it "offsets_from_start_time" do
142
- @sdp.offsets_from_start_time = 99
143
- @sdp.offsets_from_start_time.should == 99
144
- end
145
-
146
- context "time_zones" do
147
- it "one time zone" do
148
- new_values = { :adjustment_time => 111111,
149
- :offset => 99 }
150
- @sdp.time_zones << new_values
151
- @sdp.time_zones.should == [new_values]
152
- end
153
-
154
- it "two time_zones" do
155
- new_values1 = { :adjustment_time => 111111,
156
- :offset => 99 }
157
- new_values2 = { :adjustment_time => 222222,
158
- :offset => 88 }
159
- @sdp.time_zones << new_values1
160
- @sdp.time_zones << new_values2
161
- @sdp.time_zones.should == [new_values1, new_values2]
162
- end
163
- end
164
-
165
- context "encryption keys" do
166
- it "clear" do
167
- @sdp.encryption_method = 'clear'
168
- @sdp.encryption_method.should == 'clear'
169
- @sdp.encryption_key = 'password'
170
- @sdp.encryption_key.should == 'password'
171
- end
172
-
173
- it "base64" do
174
- @sdp.encryption_method = 'base64'
175
- @sdp.encryption_method.should == 'base64'
176
- enc = Base64.encode64('password')
177
- @sdp.encryption_key = enc
178
- @sdp.encryption_key.should == enc
179
- end
180
-
181
- it "uri" do
182
- @sdp.encryption_method = 'uri'
183
- @sdp.encryption_method.should == 'uri'
184
- uri = "http://aserver.com/thing.pdf"
185
- @sdp.encryption_key = uri
186
- @sdp.encryption_key.should == uri
187
- end
188
-
189
- it "prompt" do
190
- @sdp.encryption_method = 'prompt'
191
- @sdp.encryption_method.should == 'prompt'
192
- @sdp.encryption_key.should be_nil
193
- end
194
- end
195
-
196
- context "attributes" do
197
- it "one attribute with value" do
198
- new_values = { :attribute => 'rtpmap',
199
- :value => "99 h263-1998/90000" }
200
- @sdp.attributes << new_values
201
- @sdp.attributes.first.should == new_values
202
- end
203
-
204
- it "one attribute with empty value" do
205
- new_values = { :attribute => 'rtpmap',
206
- :value => "" }
207
- @sdp.attributes << new_values
208
- @sdp.attributes.first.should == new_values
209
- end
210
-
211
- it "one attribute with nil value" do
212
- new_values = { :attribute => 'rtpmap' }
213
- @sdp.attributes << new_values
214
- @sdp.attributes.first.should == new_values
215
- end
216
-
217
- it "two attributes" do
218
- new_values1 = { :attribute => 'test' }
219
- new_values2 = { :attribute => 'rtpmap',
220
- :value => "99 h263-1998/90000" }
221
- @sdp.attributes << new_values1
222
- @sdp.attributes << new_values2
223
- @sdp.attributes.should == [new_values1, new_values2]
224
- end
225
- end
226
-
227
- context "media_sections" do
228
- it "can add a basic media section" do
229
- new_values = { :media => 'audio',
230
- :port => 12345,
231
- :protocol => 'RTP/AVP',
232
- :format => 99 }
233
- @sdp.media_sections << new_values
234
- @sdp.media_sections.first.should == new_values
235
- end
236
-
237
- it "can add a basic media section with attributes" do
238
- new_values = { :media => 'audio',
239
- :port => 12345,
240
- :protocol => 'RTP/AVP',
241
- :format => 99,
242
- :attributes => [
243
- {
244
- :attribute => "rtpmap",
245
- :value => "99 h263-1998/90000"
246
- }
247
- ]
248
- }
249
- @sdp.media_sections << new_values
250
- @sdp.media_sections.first.should == new_values
251
- end
252
-
253
- it "can add 2 basic media sections" do
254
- new_values = []
255
- new_values << { :media => 'audio',
256
- :port => 12345,
257
- :protocol => 'RTP/AVP',
258
- :format => 99 }
259
- @sdp.media_sections << new_values[0]
260
-
261
- new_values << { :media => 'video',
262
- :port => 5678,
263
- :protocol => 'RTP/AVP',
264
- :format => 33 }
265
- @sdp.media_sections << new_values[1]
266
-
267
- @sdp.media_sections.class.should == Array
268
- @sdp.media_sections[0].should == new_values[0]
269
- @sdp.media_sections[1].should == new_values[1]
270
- end
271
- end
272
- end
273
-
274
- context "#to_s" do
275
- it "contains required session section values" do
276
- @sdp.to_s.should match /v=0/
277
- @sdp.to_s.should match /o=/
278
- @sdp.to_s.should match /s=/
279
- @sdp.to_s.should match /t=/
280
- end
281
-
282
- it "ends each line with \r\n" do
283
- @sdp.to_s.each_line do |l|
284
- l.should match /\r\n$/
285
- end
286
- end
287
-
288
- it "handles descriptions with no time zone" do
289
- sdp = SDP.parse(SDP_MISSING_TIME)
290
- lambda { sdp.to_s }.should_not raise_error
291
- end
292
- end
293
-
294
- context "#valid?" do
295
- before :each do
296
- @sdp = SDP::Description.new
297
-
298
- @sdp.protocol_version = 0
299
- @sdp.username = "jdoe"
300
- @sdp.id = 12345
301
- @sdp.version = 12345
302
- @sdp.network_type = :IN
303
- @sdp.address_type = :IP4
304
- @sdp.unicast_address = "127.0.0.1"
305
- @sdp.name = "This is a test"
306
- @sdp.start_time = 12345678
307
- @sdp.stop_time = 12345680
308
- @sdp.media_sections << { :media => "audio", :port => 123,
309
- :protocol => "RTP/AVP", :format => 99 }
310
- end
311
-
312
- it "is valid when all required fields have values" do
313
- @sdp.valid?.should be_true
314
- end
315
-
316
- it "is NOT valid when protocol_version isn't set" do
317
- @sdp.protocol_version = nil
318
- @sdp.valid?.should be_false
319
- end
320
-
321
- it "is NOT valid when username isn't set" do
322
- @sdp.username = nil
323
- @sdp.valid?.should be_false
324
- end
325
-
326
- it "is NOT valid when id isn't set" do
327
- @sdp.id = nil
328
- @sdp.valid?.should be_false
329
- end
330
-
331
- it "is NOT valid when version isn't set" do
332
- @sdp.version = nil
333
- @sdp.valid?.should be_false
334
- end
335
-
336
- it "is NOT valid when network_type isn't set" do
337
- @sdp.network_type = nil
338
- @sdp.valid?.should be_false
339
- end
340
-
341
- it "is NOT valid when address_type isn't set" do
342
- @sdp.address_type = nil
343
- @sdp.valid?.should be_false
344
- end
345
-
346
- it "is NOT valid when unicast_address isn't set" do
347
- @sdp.unicast_address = nil
348
- @sdp.valid?.should be_false
349
- end
350
-
351
- it "is NOT valid when name isn't set" do
352
- @sdp.name = nil
353
- @sdp.valid?.should be_false
354
- end
355
-
356
- it "is valid when name is ' '" do
357
- @sdp.name = ' '
358
- @sdp.valid?.should be_true
359
- end
360
-
361
- it "is NOT valid when start_time isn't set" do
362
- @sdp.start_time = nil
363
- @sdp.valid?.should be_false
364
- end
365
-
366
- it "is NOT valid when stop_time isn't set" do
367
- @sdp.stop_time = nil
368
- @sdp.valid?.should be_false
369
- end
370
-
371
- it "is NOT valid when media_sections is empty" do
372
- @sdp[:media_sections] = []
373
- @sdp.valid?.should be_false
374
- end
375
- end
376
-
377
- context "bad initialize values" do
378
- it "ensures a Hash is passed in" do
379
- lambda do
380
- SDP::Description.new 1
381
- end.should raise_error SDP::RuntimeError
382
- end
383
-
384
- it "handles a Hash with irrelvant keys" do
385
- session_values = { :bobo => "thing" }
386
-
387
- lambda do
388
- SDP::Description.new session_values
389
- end.should raise_error SDP::RuntimeError
390
- end
391
- end
392
- end