<commit_before>package com.kurento.demo;

import com.kurento.kmf.content.ContentEvent;
import com.kurento.kmf.content.HttpPlayerHandler;
import com.kurento.kmf.content.HttpPlayerService;
import com.kurento.kmf.content.HttpPlayerSession;
import com.kurento.kmf.media.HttpEndpoint;
import com.kurento.kmf.media.MediaPipeline;
import com.kurento.kmf.media.MediaPipelineFactory;
import com.kurento.kmf.media.PlayerEndpoint;
import com.kurento.kmf.media.ZBarFilter;
import com.kurento.kmf.media.events.CodeFoundEvent;
import com.kurento.kmf.media.events.MediaEventListener;

/**
 * HTTP Player Handler which plays a media pipeline composed by a
 * <code>PlayerEndpoint</code> with a <code>ZBarFilter</code>; using redirect
 * strategy; with JSON signalling protocol.
 * 
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * @since 1.0.0
 */
@HttpPlayerService(name = "PlayerJsonRealEventsHandler", path = "/playerJsonEvents", redirect = true, useControlProtocol = true)
public class PlayerJsonRealEventsHandler extends HttpPlayerHandler {

	private String url = "";

	@Override
	public void onContentRequest(final HttpPlayerSession session)
			throws Exception {
		MediaPipelineFactory mpf = session.getMediaPipelineFactory();
		MediaPipeline mp = mpf.create();
		session.releaseOnTerminate(mp);

		PlayerEndpoint playerEndpoint = mp.newPlayerEndpoint(

		VideoURLs.map.get("zbar")).build();
		ZBarFilter filter = mp.newZBarFilter().build();
		playerEndpoint.connect(filter);

		filter.addCodeFoundDataListener(new MediaEventListener<CodeFoundEvent>() {

			@Override
			public void onEvent(CodeFoundEvent event) {
				getLogger().info(
						"Event " + event.getType() + "-->" + event.getValue());
				if (url.equals(event.getValue())) {
					return;
				}

				url = event.getValue();
				session.publishEvent(new ContentEvent(event.getType(), event
						.getValue()));

			}
		});
		session.setAttribute("player", playerEndpoint);

		HttpEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS().build();
		filter.connect(httpEP);
		session.start(httpEP);
	}

	@Override
	public void onContentStarted(HttpPlayerSession session) {
		PlayerEndpoint playerEndpoint = (PlayerEndpoint) session
				.getAttribute("player");
		playerEndpoint.play();<commit_msg>Changed name of code found listener in ZBar demo<commit_after>package com.kurento.demo;

import com.kurento.kmf.content.ContentEvent;
import com.kurento.kmf.content.HttpPlayerHandler;
import com.kurento.kmf.content.HttpPlayerService;
import com.kurento.kmf.content.HttpPlayerSession;
import com.kurento.kmf.media.HttpEndpoint;
import com.kurento.kmf.media.MediaPipeline;
import com.kurento.kmf.media.MediaPipelineFactory;
import com.kurento.kmf.media.PlayerEndpoint;
import com.kurento.kmf.media.ZBarFilter;
import com.kurento.kmf.media.events.CodeFoundEvent;
import com.kurento.kmf.media.events.MediaEventListener;

/**
 * HTTP Player Handler which plays a media pipeline composed by a
 * <code>PlayerEndpoint</code> with a <code>ZBarFilter</code>; using redirect
 * strategy; with JSON signalling protocol.
 * 
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * @since 1.0.0
 */
@HttpPlayerService(name = "PlayerJsonRealEventsHandler", path = "/playerJsonEvents", redirect = true, useControlProtocol = true)
public class PlayerJsonRealEventsHandler extends HttpPlayerHandler {

	private String url = "";

	@Override
	public void onContentRequest(final HttpPlayerSession session)
			throws Exception {
		MediaPipelineFactory mpf = session.getMediaPipelineFactory();
		MediaPipeline mp = mpf.create();
		session.releaseOnTerminate(mp);

		PlayerEndpoint playerEndpoint = mp.newPlayerEndpoint(

		VideoURLs.map.get("zbar")).build();
		ZBarFilter filter = mp.newZBarFilter().build();
		playerEndpoint.connect(filter);

		filter.addCodeFoundListener(new MediaEventListener<CodeFoundEvent>() {

			@Override
			public void onEvent(CodeFoundEvent event) {
				getLogger().info(
						"Event " + event.getType() + "-->" + event.getValue());
				if (url.equals(event.getValue())) {
					return;
				}

				url = event.getValue();
				session.publishEvent(new ContentEvent(event.getType(), event
						.getValue()));

			}
		});
		session.setAttribute("player", playerEndpoint);

		HttpEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS().build();
		filter.connect(httpEP);
		session.start(httpEP);
	}

	@Override
	public void onContentStarted(HttpPlayerSession session) {
		PlayerEndpoint playerEndpoint = (PlayerEndpoint) session
				.getAttribute("player");
		playerEndpoint.play();
{'fraction_non_alphanumeric': 0.12261041529334213, 'fraction_numerical': 0.0013183915622940012, 'mean_word_length': 5.193197278911565, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2560275', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1352, 'n_words': 269}