Java Code Examples for com.danikula.videocache.headers.HeaderInjector

The following examples show how to use com.danikula.videocache.headers.HeaderInjector. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 5 votes vote down vote up
@Singleton
@Provides
static HttpProxyCacheServer providesHttpProxyCacheServer(@ApplicationContext Context context,HeaderInjector headerInjector) {
    return new HttpProxyCacheServer.Builder(context)
            // 1 Gb for cache
            .headerInjector(headerInjector)
            .maxCacheSize(AppCacheUtils.MAX_VIDEO_CACHE_SIZE)
            .cacheDirectory(AppCacheUtils.getVideoCacheDir(context))
            .fileNameGenerator(new VideoCacheFileNameGenerator())
            .build();
}
 
Example 2
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 5 votes vote down vote up
@Singleton
@Provides
static HttpProxyCacheServer providesHttpProxyCacheServer(@ApplicationContext Context context,HeaderInjector headerInjector) {
    return new HttpProxyCacheServer.Builder(context)
            // 1 Gb for cache
            .headerInjector(headerInjector)
            .maxCacheSize(AppCacheUtils.MAX_VIDEO_CACHE_SIZE)
            .cacheDirectory(AppCacheUtils.getVideoCacheDir(context))
            .fileNameGenerator(new VideoCacheFileNameGenerator())
            .build();
}
 
Example 3
Source Project: AndriodVideoCache   Source File: HttpUrlSourceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = NullPointerException.class)
public void testHeaderInjectorNullNotAcceptable() throws Exception {
    HeaderInjector mockedHeaderInjector = Mockito.mock(HeaderInjector.class);
    when(mockedHeaderInjector.addHeaders(Mockito.anyString())).thenReturn(null);
    SourceInfoStorage emptySourceInfoStorage = SourceInfoStorageFactory.newEmptySourceInfoStorage();
    HttpUrlSource source = new HttpUrlSource(HTTP_DATA_URL_ONE_REDIRECT, emptySourceInfoStorage, mockedHeaderInjector);
    source.open(0);
    fail("source.open should throw NPE!");
}
 
Example 4
@Test
public void testHeadersInjectorIsInvoked() throws Exception {
    HeaderInjector mockedHeaderInjector = Mockito.mock(HeaderInjector.class);

    HttpProxyCacheServer proxy = new HttpProxyCacheServer.Builder(RuntimeEnvironment.application)
            .headerInjector(mockedHeaderInjector)
            .build();

    readProxyResponse(proxy, HTTP_DATA_URL);
    proxy.shutdown();

    verify(mockedHeaderInjector, times(2)).addHeaders(HTTP_DATA_URL);   // content info & fetch data requests
}
 
Example 5
Source Project: AndriodVideoCache   Source File: HttpUrlSource.java    License: Apache License 2.0 5 votes vote down vote up
public HttpUrlSource(String url, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.sourceInfoStorage = checkNotNull(sourceInfoStorage);
    this.headerInjector = checkNotNull(headerInjector);
    SourceInfo sourceInfo = sourceInfoStorage.get(url);
    this.sourceInfo = sourceInfo != null ? sourceInfo :
            new SourceInfo(url, Integer.MIN_VALUE, ProxyCacheUtils.getSupposablyMime(url));
}
 
Example 6
Source Project: AndriodVideoCache   Source File: Config.java    License: Apache License 2.0 5 votes vote down vote up
Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.cacheRoot = cacheRoot;
    this.fileNameGenerator = fileNameGenerator;
    this.diskUsage = diskUsage;
    this.sourceInfoStorage = sourceInfoStorage;
    this.headerInjector = headerInjector;
}
 
Example 7
Source Project: DKVideoPlayer   Source File: HttpUrlSource.java    License: Apache License 2.0 5 votes vote down vote up
public HttpUrlSource(String url, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.sourceInfoStorage = checkNotNull(sourceInfoStorage);
    this.headerInjector = checkNotNull(headerInjector);
    SourceInfo sourceInfo = sourceInfoStorage.get(url);
    this.sourceInfo = sourceInfo != null ? sourceInfo :
            new SourceInfo(url, Integer.MIN_VALUE, ProxyCacheUtils.getSupposablyMime(url));
}
 
Example 8
Source Project: DKVideoPlayer   Source File: Config.java    License: Apache License 2.0 5 votes vote down vote up
Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.cacheRoot = cacheRoot;
    this.fileNameGenerator = fileNameGenerator;
    this.diskUsage = diskUsage;
    this.sourceInfoStorage = sourceInfoStorage;
    this.headerInjector = headerInjector;
}
 
Example 9
Source Project: QSVideoPlayer   Source File: Proxy.java    License: Apache License 2.0 5 votes vote down vote up
synchronized static HttpProxyCacheServer getProxy(Context context, final Map<String, String> headers) {
    if (builder == null)
        builder = new HttpProxyCacheServer.Builder(context);
    if (headers != null)
        builder.headerInjector(new HeaderInjector() {
            @Override
            public Map<String, String> addHeaders(String url) {
                return headers;
            }
        });
    return builder.build();
}
 
Example 10
Source Project: GSYVideoPlayer   Source File: HttpUrlSource.java    License: Apache License 2.0 5 votes vote down vote up
public HttpUrlSource(String url, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.sourceInfoStorage = checkNotNull(sourceInfoStorage);
    this.headerInjector = checkNotNull(headerInjector);
    SourceInfo sourceInfo = sourceInfoStorage.get(url);
    this.sourceInfo = sourceInfo != null ? sourceInfo :
            new SourceInfo(url, Integer.MIN_VALUE, ProxyCacheUtils.getSupposablyMime(url));
}
 
Example 11
Source Project: GSYVideoPlayer   Source File: Config.java    License: Apache License 2.0 5 votes vote down vote up
Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.cacheRoot = cacheRoot;
    this.fileNameGenerator = fileNameGenerator;
    this.diskUsage = diskUsage;
    this.sourceInfoStorage = sourceInfoStorage;
    this.headerInjector = headerInjector;
}
 
Example 12
Source Project: AndroidVideoCache   Source File: HttpUrlSourceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = NullPointerException.class)
public void testHeaderInjectorNullNotAcceptable() throws Exception {
    HeaderInjector mockedHeaderInjector = Mockito.mock(HeaderInjector.class);
    when(mockedHeaderInjector.addHeaders(Mockito.anyString())).thenReturn(null);
    SourceInfoStorage emptySourceInfoStorage = SourceInfoStorageFactory.newEmptySourceInfoStorage();
    HttpUrlSource source = new HttpUrlSource(HTTP_DATA_URL_ONE_REDIRECT, emptySourceInfoStorage, mockedHeaderInjector);
    source.open(0);
    fail("source.open should throw NPE!");
}
 
Example 13
@Test
public void testHeadersInjectorIsInvoked() throws Exception {
    HeaderInjector mockedHeaderInjector = Mockito.mock(HeaderInjector.class);

    HttpProxyCacheServer proxy = new HttpProxyCacheServer.Builder(RuntimeEnvironment.application)
            .headerInjector(mockedHeaderInjector)
            .build();

    readProxyResponse(proxy, HTTP_DATA_URL);
    proxy.shutdown();

    verify(mockedHeaderInjector, times(2)).addHeaders(HTTP_DATA_URL);   // content info & fetch data requests
}
 
Example 14
Source Project: AndroidVideoCache   Source File: HttpUrlSource.java    License: Apache License 2.0 5 votes vote down vote up
public HttpUrlSource(String url, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.sourceInfoStorage = checkNotNull(sourceInfoStorage);
    this.headerInjector = checkNotNull(headerInjector);
    SourceInfo sourceInfo = sourceInfoStorage.get(url);
    this.sourceInfo = sourceInfo != null ? sourceInfo :
            new SourceInfo(url, Integer.MIN_VALUE, ProxyCacheUtils.getSupposablyMime(url));
}
 
Example 15
Source Project: AndroidVideoCache   Source File: Config.java    License: Apache License 2.0 5 votes vote down vote up
Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
    this.cacheRoot = cacheRoot;
    this.fileNameGenerator = fileNameGenerator;
    this.diskUsage = diskUsage;
    this.sourceInfoStorage = sourceInfoStorage;
    this.headerInjector = headerInjector;
}
 
Example 16
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 4 votes vote down vote up
@Singleton
static @Provides HeaderInjector providesHeaderInjector(MyHeaderInjector myHeaderInjector){
    return myHeaderInjector;
}
 
Example 17
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 4 votes vote down vote up
@Singleton
static @Provides HeaderInjector providesHeaderInjector(MyHeaderInjector myHeaderInjector){
    return myHeaderInjector;
}