[pitivi] stream: add STREAM_MATCH_SAME_TYPE to stream_compare.
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] stream: add STREAM_MATCH_SAME_TYPE to stream_compare.
- Date: Wed, 22 Sep 2010 15:04:01 +0000 (UTC)
commit 0c4172a7313c1dd574eac229a47398e04c966c1d
Author: Alessandro Decina <alessandro d gmail com>
Date: Tue Sep 7 16:29:28 2010 +0200
stream: add STREAM_MATCH_SAME_TYPE to stream_compare.
STREAM_MATCH_SAME_TYPE is returned when two streams are of the same type (audio,
video, etc)
pitivi/stream.py | 11 ++++++++---
tests/test_stream.py | 13 +++++++------
2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/stream.py b/pitivi/stream.py
index 2e476d0..d28769b 100644
--- a/pitivi/stream.py
+++ b/pitivi/stream.py
@@ -27,10 +27,10 @@ from pitivi.log.loggable import Loggable
import pitivi.log.log as log
import gst
-STREAM_MATCH_MAXIMUM = 100
STREAM_MATCH_SAME_CAPS = 60
-STREAM_MATCH_SAME_PAD_NAME = 40
-STREAM_MATCH_COMPATIBLE_CAPS = 30
+STREAM_MATCH_SAME_PAD_NAME = 30
+STREAM_MATCH_COMPATIBLE_CAPS = 20
+STREAM_MATCH_SAME_TYPE = 10
STREAM_MATCH_NONE = 0
class MultimediaStream(Loggable):
@@ -444,6 +444,11 @@ def stream_compare(stream_a, stream_b):
current_rank += STREAM_MATCH_SAME_CAPS
elif stream_a.caps.intersect(stream_b.caps):
current_rank += STREAM_MATCH_COMPATIBLE_CAPS
+ else:
+ name_a = stream_a.caps[0].get_name()
+ name_b = stream_b.caps[0].get_name()
+ if name_a.split("/", 1)[0] == name_b.split("/", 1)[0]:
+ current_rank += STREAM_MATCH_SAME_TYPE
return current_rank
diff --git a/tests/test_stream.py b/tests/test_stream.py
index 7465eca..988511a 100644
--- a/tests/test_stream.py
+++ b/tests/test_stream.py
@@ -23,9 +23,9 @@
from common import TestCase
from pitivi.stream import AudioStream, VideoStream, match_stream, \
match_stream_groups, StreamGroupWalker, \
- STREAM_MATCH_MAXIMUM, STREAM_MATCH_SAME_CAPS, \
- STREAM_MATCH_COMPATIBLE_CAPS, STREAM_MATCH_NONE, \
- STREAM_MATCH_SAME_PAD_NAME
+ STREAM_MATCH_SAME_CAPS, STREAM_MATCH_COMPATIBLE_CAPS, \
+ STREAM_MATCH_NONE, STREAM_MATCH_SAME_PAD_NAME, \
+ STREAM_MATCH_SAME_TYPE
import gst
class TestMultimediaStream(object):
@@ -170,7 +170,8 @@ class TestMatchStream(TestCase):
s2 = AudioStream(gst.Caps("audio/x-speex"), pad_name="src0")
stream, rank = match_stream(s1, [s2])
self.failUnlessEqual(id(s2), id(stream))
- self.failUnlessEqual(rank, STREAM_MATCH_SAME_PAD_NAME)
+ self.failUnlessEqual(rank, STREAM_MATCH_SAME_PAD_NAME +
+ STREAM_MATCH_SAME_TYPE)
def testMatchStreamCompatibleCaps(self):
s1 = AudioStream(gst.Caps("audio/x-vorbis, a={1, 2}"))
@@ -186,7 +187,6 @@ class TestMatchStream(TestCase):
self.failUnlessEqual(id(s2), id(stream))
self.failUnlessEqual(rank,
STREAM_MATCH_SAME_PAD_NAME + STREAM_MATCH_SAME_CAPS)
- self.failUnlessEqual(rank, STREAM_MATCH_MAXIMUM)
def testMatchStreamSameNameAndCompatibleCaps(self):
s1 = AudioStream(gst.Caps("audio/x-vorbis, a={1, 2}"), pad_name="src0")
@@ -238,7 +238,8 @@ class TestStreamGroupMatching(TestCase):
walker = walkers[1]
self.failUnlessEqual(walker.advance(), [])
- self.failUnlessEqual(walker.getMatches(), {})
+ self.failUnlessEqual(walker.getMatches(),
+ {(stream2, stream3): STREAM_MATCH_SAME_TYPE})
def testMatchStreamGroupsOrder(self):
stream1 = AudioStream(gst.Caps("audio/x-vorbis"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]