rstreamor 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2917bc3f4ceb7e49d8bf2ce9a8a8a784800261e
4
- data.tar.gz: bdaab2583015a8f27ccf380153131fd63292e19c
3
+ metadata.gz: a114369ba9a80a9fee20d8aca564c850c072fab9
4
+ data.tar.gz: d210db8229bd6674e5986ed0af1725a7a56978d2
5
5
  SHA512:
6
- metadata.gz: 68af7208404956aa3790a5b348b2b1c64cb3110e8b1c4c0b56f3777b08166a1fb135a091669d87215b1e48b55fb8229c24fce12552a997d4decb7c7836bf9d61
7
- data.tar.gz: 125a769788b7ce6018e6088aca988dc83df98d3a3045c4aca94f08aed404b9751ef7f7d3651af02f0fa9eae89f3c61873cf4a9750f462c7f7d95d3eeaba1e4ac
6
+ metadata.gz: ec343f4bebd927818fbc4818b7077ab99aaf05479d481c5f33e5fba0394d9f5c1bd55835144b4809caa5251bab63a3016ae425c4c1995099bb5df8964d053105
7
+ data.tar.gz: 8f5e8a1814c84547e62f2c2bb2fd85207055365b7eb23991d218b16faa2dc883a928d90e71c015c2bbd4b4434ff25983446e3b394b75cdb2e997bb8cecfa3b4f
data/README.md CHANGED
@@ -1,30 +1,36 @@
1
1
  # Rstreamor
2
- Development in progress...
2
+ Stream your data using HTTP/1.1 range requests and partial responses.
3
3
 
4
4
  # Get Rstreamor
5
5
  ###### Directly from GitHub
6
6
  ```ruby
7
- gem 'regressor', git: 'https://github.com/ndea/rstreamor.git', branch: 'master'
7
+ gem 'rstreamor', git: 'https://github.com/ndea/rstreamor.git', branch: 'master'
8
8
  ```
9
9
  ###### Rubygems
10
+ ```ruby
11
+ gem 'rstreamor', '~> 0.2.1'
12
+ ```
10
13
  # Install
11
14
  ```ruby
12
15
  bundle install
13
16
  ```
14
17
  # Usage
15
- Given you have a controller with a streaming action (here it's the show action) simply use following code:
18
+ In combination with Carrierwave
19
+ ```ruby
20
+ class Profile < ActiveRecord::Base
21
+ mount_uploader :image_file, ProfileImageUploader
22
+ end
23
+ ```
16
24
  ```ruby
17
25
  class VideosController < ApplicationController
18
26
  include Rstreamor
19
27
  def show
20
- stream @resource.file
28
+ stream @resource.image_file
21
29
  end
22
30
  end
23
31
  ```
24
- Please note that the file method of @resource is a mounted uploader of carrierwave.
25
-
26
32
  Rstreamor takes care of the rest.
27
- If you dont use Carrierwave as a file make sure your file has the following methods:
33
+ If you dont use Carrierwave as a file make sure your file method has the following methods defined:
28
34
  - #data
29
35
  - #content_type
30
36
 
@@ -35,7 +41,42 @@ Byte serving is the process of sending only a portion of an HTTP/1.1 message fro
35
41
  Consider you have a large video or audio file on your server which needs to be served partially to your client. You don't want to send the whole file in one response (unless you want to download the file). Instead the client needs only partial content which he can view and request other partial content if needed. Rstreamor provides this byte serving mechanism defined in HTTP/1.1.
36
42
 
37
43
  ###### Example
38
- ###### Limitations
44
+ Example of the request - response flow
45
+ Consider simple HTML5 video streaming.
46
+ ```html
47
+ <video width="320" height="240" controls>
48
+ <source src="http://..." type="video/mp4">
49
+ Your browser does not support the video tag.
50
+ </video>
51
+ ```
52
+ The first request fired by the client contains the following header
53
+ ```bash
54
+ Range:bytes=0-
55
+ ```
56
+ and requests the whole file from the server starting from 0 till end. The server then responds with the following headers
57
+ ```bash
58
+ Accept-Ranges:bytes
59
+ Cache-Control:no-cache
60
+ Content-Disposition:inline
61
+ Content-Length:6642801
62
+ Content-Range:bytes 0-6642800/6642801
63
+ Content-Transfer-Encoding:binary
64
+ Content-Type:application/mp4
65
+ ```
66
+ Now let's skip through our video and seek for a certain scene - the client now sends the following request header
67
+ ```bash
68
+ Range:bytes=3303604-
69
+ ```
70
+ And the server responds with the following response headers
71
+ ```bash
72
+ Accept-Ranges:bytes
73
+ Cache-Control:no-cache
74
+ Content-Disposition:inline
75
+ Content-Length:3339197
76
+ Content-Range:bytes 3303604-6642800/6642801
77
+ Content-Transfer-Encoding:binary
78
+ Content-Type:application/mp4
79
+ ```
39
80
  # Contributing
40
81
 
41
82
  1. Fork it ( https://github.com/ndea/regressor/fork )
@@ -7,7 +7,11 @@ module Rstreamor
7
7
  end
8
8
 
9
9
  def data
10
- self.file.data
10
+ if self.file.respond_to? :data
11
+ self.file.data
12
+ else
13
+ self.file.read
14
+ end
11
15
  end
12
16
 
13
17
  def content_type
@@ -1,3 +1,3 @@
1
1
  module Rstreamor
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rstreamor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Schens