Skip to content
Browse files

Merge branch 'socket_repo'

  • Loading branch information...
2 parents 2e9ee2b + 58ef86e commit af21da47dd63da52b7bb2c721d0175a6a811ecdb @takeda takeda committed May 24, 2012
Showing with 20 additions and 6 deletions.
  1. +1 −2 videostreaming/audio_sink.py
  2. +18 −2 videostreaming/utils.py
  3. +1 −2 videostreaming/video_sink.py
View
3 videostreaming/audio_sink.py
@@ -18,8 +18,7 @@ class CCNAudioPacketizer(CCNPacketizer):
def __init__(self, repolocation, uri):
self.last_index = None
- handle = pyccn.CCN()
- publisher = utils.RepoPublisher(handle, 'audio', repolocation)
+ publisher = utils.RepoSocketPublisher()
super(CCNAudioPacketizer, self).__init__(publisher, uri)
def pre_process_buffer(self, buffer):
View
20 videostreaming/utils.py
@@ -2,7 +2,7 @@
pygst.require('0.10')
import gst
-import struct, time, Queue, bisect, threading, math, os, platform, random
+import struct, time, Queue, bisect, threading, math, os, platform, random, socket
from operator import itemgetter
import pyccn
from pyccn import _pyccn
@@ -49,7 +49,6 @@ def framerate2str(framerate):
return fr_str
class RepoPublisher(pyccn.Closure):
-
def __init__(self, handle, prefix, repo_loc = None):
self._sequence = 0;
@@ -83,6 +82,23 @@ def put(self, content):
def upcall(self, kind, info):
return pyccn.RESULT_OK
+class RepoSocketPublisher(pyccn.Closure):
+ def __init__(self, repo_port = None):
+ if not repo_port:
+ if not os.environ.has_key('CCNR_STATUS_PORT'):
+ raise Exception("CCNR_STATUS_PORT not defined and no repo port specified")
+
+ repo_port = os.environ['CCNR_STATUS_PORT']
+
+ self.repo_dest = ('127.0.0.1', int(repo_port))
+
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.sock.connect(self.repo_dest)
+
+ def put(self, content):
+ self.sock.send(_pyccn.dump_charbuf(content.ccn_data))
+# self.sock.flush()
+
class RingBuffer:
def __init__(self, size):
self.data = [None for i in xrange(size)]
View
3 videostreaming/video_sink.py
@@ -14,8 +14,7 @@ class CCNVideoPacketizer(CCNPacketizer):
def __init__(self, repolocation, uri):
# self._tc = None
- handle = pyccn.CCN()
- publisher = utils.RepoPublisher(handle, 'video', repolocation)
+ publisher = utils.RepoSocketPublisher()
super(CCNVideoPacketizer, self).__init__(publisher, uri)
# def post_set_caps(self, caps):

0 comments on commit af21da4

Please sign in to comment.
Something went wrong with that request. Please try again.