]> git.basschouten.com Git - openhab-addons.git/blob
59632d4f11e637e11a2c7e4e835c6d27b1e669cc
[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  * @author Matthew Skinner - Initial contribution
26  */
27 @NonNullByDefault
28 public class NettyRtspHandler extends ChannelDuplexHandler {
29     RtspConnection rtspConnection;
30
31     NettyRtspHandler(RtspConnection rtspConnection) {
32         this.rtspConnection = rtspConnection;
33     }
34
35     @Override
36     public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object msg) throws Exception {
37         if (msg == null || ctx == null) {
38             return;
39         }
40         if (!(msg instanceof LastHttpContent)) {
41             rtspConnection.processMessage(msg);
42         } else {
43             ctx.close();
44         }
45     }
46
47     @Override
48     public void channelReadComplete(@Nullable ChannelHandlerContext ctx) {
49     }
50
51     @Override
52     public void handlerAdded(@Nullable ChannelHandlerContext ctx) {
53     }
54
55     @Override
56     public void handlerRemoved(@Nullable ChannelHandlerContext ctx) {
57     }
58
59     @Override
60     public void exceptionCaught(@Nullable ChannelHandlerContext ctx, @Nullable Throwable cause) {
61     }
62
63     @Override
64     public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception {
65     }
66 }