Permalink
Browse files

added createStream message

  • Loading branch information...
sile committed Oct 12, 2012
1 parent 72aa319 commit 5e469b4a527c7f410712d0d97656f9e8f700938d
Showing with 52 additions and 8 deletions.
  1. +44 −7 message/message.lisp
  2. +3 −1 message/package.lisp
  3. +5 −0 server/server.lisp
View
@@ -37,6 +37,38 @@
(name t :type string)
(transaction-id t :type number))
+(defstruct (create-stream (:include command-base))
+ (command-object t :type (or list-map (member :null))))
+
+(defun create-stream (transaction-id command-object &key (timestamp (get-internal-real-time))
+ (stream-id 0) ; use default channel
+ (amf-version 0))
+ (declare ((member 0 3) amf-version))
+ (assert (= amf-version 0) () "unsupported AMF version: ~a" amf-version)
+
+ (make-create-stream :type-id +MESSAGE_TYPE_ID_COMMAND_AMF0+
+ :stream-id stream-id
+ :timestamp timestamp
+ :name "createStream"
+ :transaction-id transaction-id
+ :command-object command-object))
+
+(defmethod write-command (out (m create-stream))
+ (with-slots (command-object) m
+ (rtmp.amf0:encode command-object out)))
+
+(defun parse-command-create-stream (in transaction-id stream-id timestamp)
+ (let ((obj (rtmp.amf0:decode in)))
+ (assert (not (listen in)) () "stream is n't consumed")
+ (create-stream transaction-id
+ obj
+ :stream-id stream-id
+ :timestamp timestamp)))
+
+(defmethod show-fields ((m create-stream))
+ (with-slots (command-object) m
+ (princ-to-string command-object)))
+
;; TODO: 仕様 or 実装 を探す
(defstruct (fcpublish (:include command-base))
field1
@@ -96,11 +128,15 @@
:field2 field2))
+(defmethod show-fields ((m command-base))
+ (declare (ignore m))
+ "")
+
(defmethod show ((m command-base))
(with-slots (type-id stream-id timestamp name transaction-id) m
(let ((*print-pretty* nil))
- (format nil "(~s \"~d:~d:~d\" ~d)"
- name type-id stream-id timestamp transaction-id))))
+ (format nil "(~s \"~d:~d:~d\" ~d ~a)"
+ name type-id stream-id timestamp transaction-id (show-fields m)))))
(defmethod write-command (out (m release-stream))
(with-slots (field1 field2) m
@@ -147,8 +183,8 @@
:field1 obj)))
(defstruct (_result (:include command-base))
- (properties t :type list-map)
- (information t :type list-map))
+ (properties t :type (or list-map (member :null)))
+ (information t :type t))
(defun _result (transaction-id properties information
&key (timestamp (get-internal-real-time))
@@ -174,8 +210,8 @@
(defmethod write-command (out (m _result))
(with-slots (properties information) m
- (rtmp.amf0:encode `(:map ,properties) out)
- (rtmp.amf0:encode `(:map ,information) out)))
+ (rtmp.amf0:encode (if (listp properties) `(:map ,properties) properties) out) ; XXX:
+ (rtmp.amf0:encode (if (listp information) `(:map ,information) information) out)))
(defun parse-command-_result (in transaction-id stream-id timestamp)
(let ((properties (rtmp.amf0:decode in))
@@ -191,7 +227,7 @@
(optional-args t :type list-map))
(defun connect (command-object &key (timestamp (get-internal-real-time))
- (stream-id (next-message-stream-id))
+ (stream-id 0) ; use default channel (net.connection)
optional-args
(amf-version 0))
(declare ((member 0 3) amf-version))
@@ -260,6 +296,7 @@
(show-log "command-name# ~s" command-name)
(ecase command
(:connect (parse-command-connect in transaction-id stream-id timestamp))
+ (:createStream (parse-command-create-stream in transaction-id stream-id timestamp))
(:_result (parse-command-_result in transaction-id stream-id timestamp))
(:onBWDone (parse-command-on-bandwidth-done in transaction-id stream-id timestamp))
(:releaseStream (parse-command-release-stream in transaction-id stream-id timestamp))
View
@@ -4,7 +4,9 @@
(:export ;;; command
connect
_result
-
+ _error
+ create-stream
+
on-bandwidth-done
release-stream
fcpublish
View
@@ -56,6 +56,11 @@
(rtmp.message:fcpublish
(show-log "recv FCPublish# stream-id=~s" (rtmp.message::fcpublish-field2 msg)))
+ (rtmp.message:create-stream
+ (let ((transaction-id (rtmp.message::command-base-transaction-id msg))
+ (stream-id 1234)) ; XXX: dummy
+ (rtmp.message:write io (rtmp.message:_result transaction-id :null stream-id))))
+
)))
(values))

0 comments on commit 5e469b4

Please sign in to comment.