]> git.basschouten.com Git - openhab-addons.git/blob
40b1b893bb9484658a4cd6ee2fe8675da5aa934a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.ipcamera.internal.rtsp;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 import io.netty.channel.ChannelDuplexHandler;
19 import io.netty.channel.ChannelHandlerContext;
20 import io.netty.handler.codec.http.LastHttpContent;
21
22 /**
23  * The {@link NettyRtspHandler} is used to decode RTSP traffic into message Strings.
24  *
25  *
26  * @author Matthew Skinner - Initial contribution
27  */
28 @NonNullByDefault
29 public class NettyRtspHandler extends ChannelDuplexHandler {
30     RtspConnection rtspConnection;
31
32     NettyRtspHandler(RtspConnection rtspConnection) {
33         this.rtspConnection = rtspConnection;
34     }
35
36     @Override
37     public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object msg) throws Exception {
38         if (msg == null || ctx == null) {
39             return;
40         }
41         if (!(msg instanceof LastHttpContent)) {
42             rtspConnection.processMessage(msg);
43         } else {
44             ctx.close();
45         }
46     }
47
48     @Override
49     public void channelReadComplete(@Nullable ChannelHandlerContext ctx) {
50     }
51
52     @Override
53     public void handlerAdded(@Nullable ChannelHandlerContext ctx) {
54     }
55
56     @Override
57     public void handlerRemoved(@Nullable ChannelHandlerContext ctx) {
58     }
59
60     @Override
61     public void exceptionCaught(@Nullable ChannelHandlerContext ctx, @Nullable Throwable cause) {
62     }
63
64     @Override
65     public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception {
66     }
67 }