|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This class is used to mark and seek the inputstream. At present it is |
|
15 * implemented to mark and seek to the front of the stream and not anywhere |
|
16 * in the middle as the use case only demands such a beahaviour. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 package com.nokia.microedition.media; |
|
22 |
|
23 import java.io.IOException; |
|
24 import java.io.InputStream; |
|
25 |
|
26 /** |
|
27 * Class InputStreamSeekControl used to mark and seek the inputstream |
|
28 */ |
|
29 public class InputStreamSeekControl implements SeekControl |
|
30 { |
|
31 |
|
32 |
|
33 private InputStream iInputStream; |
|
34 |
|
35 /** |
|
36 * Constructor |
|
37 */ |
|
38 public InputStreamSeekControl() |
|
39 { |
|
40 |
|
41 iInputStream = null; |
|
42 } |
|
43 |
|
44 /* |
|
45 * Constructor |
|
46 * @param aInputStream - inputstream used by the InputStream class |
|
47 * that needs to be marked and streamed |
|
48 */ |
|
49 public InputStreamSeekControl(InputStream aInputStream) |
|
50 { |
|
51 |
|
52 iInputStream = aInputStream; |
|
53 |
|
54 if (iInputStream.markSupported() == true) |
|
55 { |
|
56 iInputStream.mark(0); |
|
57 } |
|
58 } |
|
59 |
|
60 /* |
|
61 * Method seeks to the start of the inputstream. |
|
62 * @param aWhere - is ignored as the seeking takes place to |
|
63 * the begining always |
|
64 */ |
|
65 public void seek(int aWhere) throws IOException |
|
66 { |
|
67 |
|
68 |
|
69 if (iInputStream.markSupported() == true) |
|
70 { |
|
71 iInputStream.reset(); |
|
72 } |
|
73 } |
|
74 |
|
75 public void close() |
|
76 { |
|
77 |
|
78 // intentionally left blank |
|
79 } |
|
80 |
|
81 } |