/*******************************************************************************
 * ADOBE SYSTEMS INCORPORATED
 * Copyright 2014 Adobe Systems Incorporated
 * All Rights Reserved.
 *
 * NOTICE:  Adobe permits you to use, modify, and distribute this file in
 * accordance with the  terms of the Adobe license agreement accompanying it. If
 * you have received this file from a source other than Adobe, then your use,
 * modification, or distribution of it requires the prior written permission of
 * Adobe.
 *******************************************************************************/

package com.adobe.primetime.reference.advertising;

import com.adobe.mediacore.ContentFactory;
import com.adobe.mediacore.MediaPlayerItem;
import com.adobe.mediacore.MediaResource;
import com.adobe.mediacore.metadata.AuditudeSettings;
import com.adobe.mediacore.metadata.AdvertisingMetadata;
import com.adobe.mediacore.metadata.MetadataKeys;
import com.adobe.mediacore.metadata.Metadata;
import com.adobe.mediacore.timeline.advertising.AuditudeResolver;
import com.adobe.mediacore.timeline.generators.AdSignalingModeOpportunityGenerator;
import com.adobe.mediacore.timeline.generators.SpliceOutOpportunityGenerator;
import com.adobe.mediacore.timeline.generators.OpportunityGenerator;
import com.adobe.mediacore.timeline.advertising.ContentResolver;
import com.adobe.mediacore.timeline.advertising.policy.AdPolicySelector;
import com.adobe.mediacore.timeline.advertising.CustomAdHandler;
import com.adobe.primetime.reference.PrimetimeReference;

import java.util.List;
import java.util.ArrayList;
import android.util.Log;

public class SpliceInContentFactory extends ContentFactory {
	private ContentResolver auditudeResolver;
	
	public SpliceInContentFactory() {}
	
	public List<ContentResolver> retrieveResolvers(MediaPlayerItem item) {
		
		PrimetimeReference.logger.i("SpliceInContentFactory", "inside retrieveResolvers.");
		
		List<ContentResolver> resolvers = new ArrayList<ContentResolver>();
		
		if (item != null) {
			AdvertisingMetadata metadata = null;
			
			if (item.getConfig() != null) {
				metadata = item.getConfig().getAdvertisingMetadata();
			
				if (metadata != null) {
					resolvers.add(new AuditudeResolver());
				}
				resolvers.add(new SpliceInCustomResolver());
			}
		}
        return resolvers;
	}

    public List<OpportunityGenerator> retrieveGenerators(MediaPlayerItem item)
    {
		PrimetimeReference.logger.i("SpliceInContentFactory", "inside retrieveGenerators.");
		
    	List<OpportunityGenerator> generators = new ArrayList<OpportunityGenerator>();
		generators.add(new AdSignalingModeOpportunityGenerator());
		generators.add(new SpliceInOpportunityGenerator());
        generators.add(new SpliceOutOpportunityGenerator());
        return generators;
    }

    public AdPolicySelector retrieveAdPolicySelector(MediaPlayerItem item) {
    	return null;
    }
    
    public List<CustomAdHandler> retrieveCustomAdPlaybackHandlers(MediaPlayerItem item) {
		return null;
    }
}
