From 05eb43665f3efe9255dc5391e2b8b2d116903473 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Wed, 28 Nov 2012 16:42:06 +0000 Subject: [PATCH] --- src/com/upc/pbe/upcnews/List.java | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/upc/pbe/upcnews/ParentList.java | 27 +++++++++++++++++++++++++++ src/com/upc/pbe/upcnews/Parser.java | 47 ++++++++++++++++++++++++----------------------- src/com/upc/pbe/upcnews/Playlist.java | 12 ------------ src/com/upc/pbe/upcnews/SegmentList.java | 53 ----------------------------------------------------- 5 files changed, 115 insertions(+), 88 deletions(-) create mode 100644 src/com/upc/pbe/upcnews/List.java create mode 100644 src/com/upc/pbe/upcnews/ParentList.java delete mode 100644 src/com/upc/pbe/upcnews/SegmentList.java diff --git a/src/com/upc/pbe/upcnews/List.java b/src/com/upc/pbe/upcnews/List.java new file mode 100644 index 0000000..f0412eb --- /dev/null +++ b/src/com/upc/pbe/upcnews/List.java @@ -0,0 +1,64 @@ +package com.upc.pbe.upcnews; + +import java.util.ArrayList; + +public class List +{ + private boolean validated; + private int sequenceFirst; + private int maxDuration; + private ArrayList segments; + private ParentList parent; + + public List() + { + validated = false; + segments = new ArrayList(); + } + + public void setValidated(boolean val) + { + validated = val; + } + + public boolean getValidated() + { + return validated; + } + + public void setSequence(int seq) + { + sequenceFirst = seq; + } + + public int getSequence() + { + return sequenceFirst; + } + + public void setMaxDuration(int dur) + { + maxDuration = dur; + } + + public int getMaxDuration() + { + return maxDuration; + } + + public void setParent(ParentList p) + { + parent = p; + } + + public ParentList getParent() + { + return parent; + } + + public ArrayList getSegments() + { + return segments; + } +} + diff --git a/src/com/upc/pbe/upcnews/ParentList.java b/src/com/upc/pbe/upcnews/ParentList.java new file mode 100644 index 0000000..195843b --- /dev/null +++ b/src/com/upc/pbe/upcnews/ParentList.java @@ -0,0 +1,27 @@ +package com.upc.pbe.upcnews; + +import java.util.ArrayList; + +public class ParentList +{ + int currentID; + ArrayList lists; //per cada qualitat + + public ParentList() + { + currentID = 0; + lists = new ArrayList(); + } + + public int getCurrent() + { + return currentID; + } + + public ArrayList getLists() + { + return lists; + } + + +} diff --git a/src/com/upc/pbe/upcnews/Parser.java b/src/com/upc/pbe/upcnews/Parser.java index 0e10a0d..ed771c9 100644 --- a/src/com/upc/pbe/upcnews/Parser.java +++ b/src/com/upc/pbe/upcnews/Parser.java @@ -1,39 +1,40 @@ package com.upc.pbe.upcnews; +import java.util.ArrayList; + public class Parser -{ - private SegmentList playlist; - +{ private static final String STARTWORD = "#EXTM3U"; - public Parser() - { - - } + private int currentLine; + private int currentSegment; + private int currentList; - public void setPlaylist(SegmentList pls) + public Parser() { - playlist = pls; + currentLine = 0; + currentSegment = 0; + currentList = 0; } - public SegmentList getPlaylist() + public ArrayList parseFile(String file) throws ErrorException, WarningException, InfoException { - return playlist; + ArrayList lists = new ArrayList(); + lists.add(new ParentList()); + lists.get(0).getLists().add(new List()); + String[] lines = file.split("\n"); + for(int i = 0; i < lines.length; i++) + { + parseLine(lines[i],lists); + } + return lists; } - public void parseLine(String line) throws ErrorException, WarningException, InfoException + public void parseLine(String line, ArrayList lists) throws ErrorException, WarningException, InfoException { - SegmentList pls = getPlaylist(); - int currentLine = 0; - int currentSegment = 0; boolean expectSegment = false; boolean expectList = false; - if(pls == null) - { - throw new ErrorException("Playlist uninitialized"); - } - if(line.isEmpty()) { currentLine++; @@ -41,6 +42,7 @@ public class Parser } else { + List pls = lists.get(currentList).getLists().get(lists.get(currentList).currentID); if(!pls.getValidated()) { if(line.equals(STARTWORD)) @@ -59,7 +61,6 @@ public class Parser if(line.substring(0,4).equals("#EXT")) { String[] extTag = line.split(":"); - //switch(extTag[0]) Esto no se puede usar hasta JDK7 y Android no lo permite, diffikultyz??? if(extTag[0].equals("#EXT-X-MEDIA-SEQUENCE")) { pls.setSequence(Integer.parseInt(extTag[1])); @@ -87,8 +88,8 @@ public class Parser else if(extTag[0].equals("#EXT-X-STREAM-INF")) { - /*EXTXSTREAM=1 - PROGRAMID="" + expectList = true; + /*PROGRAMID="" CODECS="" RESOLUTION="" ARGUMENTS=`echo $line | cut -d':' -f 2` diff --git a/src/com/upc/pbe/upcnews/Playlist.java b/src/com/upc/pbe/upcnews/Playlist.java index 1812c49..e69de29 100644 --- a/src/com/upc/pbe/upcnews/Playlist.java +++ b/src/com/upc/pbe/upcnews/Playlist.java @@ -1,12 +0,0 @@ -package com.upc.pbe.upcnews; - -public class Playlist -{ - private SegmentList segmentList; - - public Playlist() - { - segmentList = new SegmentList(); - } - -} diff --git a/src/com/upc/pbe/upcnews/SegmentList.java b/src/com/upc/pbe/upcnews/SegmentList.java deleted file mode 100644 index ca2bf0e..0000000 --- a/src/com/upc/pbe/upcnews/SegmentList.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.upc.pbe.upcnews; - -import java.util.ArrayList; - -public class SegmentList -{ - private boolean validated; - private int sequenceFirst; - private int maxDuration; - private ArrayList segments; - - public SegmentList() - { - validated = false; - segments = new ArrayList(); - } - - public void setValidated(boolean val) - { - validated = val; - } - - public boolean getValidated() - { - return validated; - } - - public void setSequence(int seq) - { - sequenceFirst = seq; - } - - public int getSequence() - { - return sequenceFirst; - } - - public void setMaxDuration(int dur) - { - maxDuration = dur; - } - - public int getMaxDuration() - { - return maxDuration; - } - - public ArrayList getSegments() - { - return segments; - } -} - -- libgit2 0.22.2