1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.tv.dvr; 18 19 import android.support.annotation.MainThread; 20 import android.support.annotation.Nullable; 21 import android.util.Range; 22 23 import com.android.tv.common.recording.RecordedProgram; 24 25 import java.util.List; 26 27 /** 28 * Read only data manager. 29 */ 30 @MainThread 31 public interface DvrDataManager { 32 long NEXT_START_TIME_NOT_FOUND = -1; 33 isInitialized()34 boolean isInitialized(); 35 36 /** 37 * Returns past recordings. 38 */ getRecordedPrograms()39 List<RecordedProgram> getRecordedPrograms(); 40 41 /** 42 * Returns all {@link ScheduledRecording} regardless of state. 43 */ getAllScheduledRecordings()44 List<ScheduledRecording> getAllScheduledRecordings(); 45 46 /** 47 * Returns started recordings that expired. 48 */ getStartedRecordings()49 List<ScheduledRecording> getStartedRecordings(); 50 51 /** 52 * Returns scheduled but not started recordings that have not expired. 53 */ getNonStartedScheduledRecordings()54 List<ScheduledRecording> getNonStartedScheduledRecordings(); 55 56 /** 57 * Returns season recordings. 58 */ getSeasonRecordings()59 List<SeasonRecording> getSeasonRecordings(); 60 61 /** 62 * Returns the next start time after {@code time} or {@link #NEXT_START_TIME_NOT_FOUND} 63 * if none is found. 64 * 65 * @param time time milliseconds 66 */ getNextScheduledStartTimeAfter(long time)67 long getNextScheduledStartTimeAfter(long time); 68 69 /** 70 * Returns a list of all Recordings with a overlap with the given time period inclusive. 71 * 72 * <p> A recording overlaps with a period when 73 * {@code recording.getStartTime() <= period.getUpper() && 74 * recording.getEndTime() >= period.getLower()}. 75 * 76 * @param period a time period in milliseconds. 77 */ getRecordingsThatOverlapWith(Range<Long> period)78 List<ScheduledRecording> getRecordingsThatOverlapWith(Range<Long> period); 79 80 /** 81 * Add a {@link ScheduledRecordingListener}. 82 */ addScheduledRecordingListener(ScheduledRecordingListener scheduledRecordingListener)83 void addScheduledRecordingListener(ScheduledRecordingListener scheduledRecordingListener); 84 85 /** 86 * Remove a {@link ScheduledRecordingListener}. 87 */ removeScheduledRecordingListener(ScheduledRecordingListener scheduledRecordingListener)88 void removeScheduledRecordingListener(ScheduledRecordingListener scheduledRecordingListener); 89 90 /** 91 * Add a {@link RecordedProgramListener}. 92 */ addRecordedProgramListener(RecordedProgramListener listener)93 void addRecordedProgramListener(RecordedProgramListener listener); 94 95 /** 96 * Remove a {@link RecordedProgramListener}. 97 */ removeRecordedProgramListener(RecordedProgramListener listener)98 void removeRecordedProgramListener(RecordedProgramListener listener); 99 100 /** 101 * Returns the scheduled recording program with the given recordingId or null if is not found. 102 */ 103 @Nullable getScheduledRecording(long recordingId)104 ScheduledRecording getScheduledRecording(long recordingId); 105 106 107 /** 108 * Returns the scheduled recording program with the given programId or null if is not found. 109 */ 110 @Nullable getScheduledRecordingForProgramId(long programId)111 ScheduledRecording getScheduledRecordingForProgramId(long programId); 112 113 /** 114 * Returns the recorded program with the given recordingId or null if is not found. 115 */ 116 @Nullable getRecordedProgram(long recordingId)117 RecordedProgram getRecordedProgram(long recordingId); 118 119 interface ScheduledRecordingListener { onScheduledRecordingAdded(ScheduledRecording scheduledRecording)120 void onScheduledRecordingAdded(ScheduledRecording scheduledRecording); 121 onScheduledRecordingRemoved(ScheduledRecording scheduledRecording)122 void onScheduledRecordingRemoved(ScheduledRecording scheduledRecording); 123 onScheduledRecordingStatusChanged(ScheduledRecording scheduledRecording)124 void onScheduledRecordingStatusChanged(ScheduledRecording scheduledRecording); 125 } 126 127 interface RecordedProgramListener { onRecordedProgramAdded(RecordedProgram recordedProgram)128 void onRecordedProgramAdded(RecordedProgram recordedProgram); 129 onRecordedProgramChanged(RecordedProgram recordedProgram)130 void onRecordedProgramChanged(RecordedProgram recordedProgram); 131 onRecordedProgramRemoved(RecordedProgram recordedProgram)132 void onRecordedProgramRemoved(RecordedProgram recordedProgram); 133 } 134 } 135