Skip to content

Commit

Permalink
#849: only send caps when they change, keep a copy and report it via …
Browse files Browse the repository at this point in the history
…xpra info

git-svn-id: https://xpra.org/svn/Xpra/trunk@10255 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 11, 2015
1 parent bc9df77 commit 3a14229
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/xpra/sound/src.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(self, src_type=None, src_options={}, codecs=CODECS, codec_options={
self.setup_pipeline_and_bus(pipeline_els)
self.volume = self.pipeline.get_by_name("volume")
self.sink = self.pipeline.get_by_name("sink")
self.caps = None
if JITTER>0:
self.jitter_queue = Queue()
try:
Expand All @@ -82,6 +83,13 @@ def cleanup(self):
SoundPipeline.cleanup(self)
self.src_type = ""
self.sink = None
self.caps = None

def get_info(self):
info = SoundPipeline.get_info(self)
if self.caps:
info["caps"] = self.caps.to_string()
return info


def on_new_preroll1(self, appsink):
Expand Down Expand Up @@ -115,7 +123,7 @@ def on_new_buffer(self, bus):
return self.emit_buffer0(buf)


def emit_buffer0(self, buf, metadata={}):
def emit_buffer0(self, buf):
""" convert pygst structure into something more generic for the wire """
#none of the metadata is really needed at present, but it may be in the future:
#metadata = {"caps" : buf.get_caps().to_string(),
Expand All @@ -125,11 +133,14 @@ def emit_buffer0(self, buf, metadata={}):
# "offset" : buf.offset,
# "offset_end": buf.offset_end}
log("emit buffer: %s bytes, timestamp=%s", len(buf.data), buf.timestamp//MS_TO_NS)
return self.emit_buffer(buf.data, {
"caps" : buf.get_caps().to_string(),
"timestamp" : normv(buf.timestamp),
"duration" : normv(buf.duration)
})
metadata = {
"timestamp" : normv(buf.timestamp),
"duration" : normv(buf.duration)
}
if not self.caps or self.caps.to_string()!=buf.get_caps():
self.caps = buf.get_caps()
metadata["caps"] = self.caps.to_string()
return self.emit_buffer(buf.data, metadata)

def emit_buffer(self, data, metadata={}):
if JITTER>0:
Expand Down

0 comments on commit 3a14229

Please sign in to comment.