Created
July 16, 2020 21:36
-
-
Save fernandoc1/edf7557754ed31a3a41d93c64e567f1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CXX := arm-hisiv300-linux-g++ | |
| CC := arm-hisiv300-linux-gcc | |
| BIN := REVOSender | |
| INC_FLAGS := -I ../libStreamServer/libGetDVStream | |
| INC_FLAGS += -I ../libStreamServer/libDVStream | |
| INC_FLAGS += -I ../libStreamServer/libIpcUtils | |
| INC_FLAGS += -I../REVOServer | |
| INC_FLAGS += -I../libCipher | |
| CFLAGS := -Wall -ldl -lm -lpthread -lrt -fPIC #-g #DEBUG | |
| OBJS := REVOSender.o | |
| OBJS += ../REVOServer/sha256.o | |
| OBJS += ../REVOServer/i2c_eeprom.o | |
| LIBS := ../libStreamServer/libGetDVStream/libGetDVStream.a | |
| LIBS += ../libStreamServer/libDVStream/libDVStream.a | |
| LIBS += ../libStreamServer/libIpcUtils/libIpcUtils.a | |
| LIBS += ../libAppConfig/libAppConfig.a | |
| LIBS += ../libCipher/libCipher.a | |
| .PHONY : all | |
| %.o: %.cpp | |
| $(CXX) $(CFLAGS) $(INC_FLAGS) -c $< -o $@ | |
| %.o: %.c | |
| $(CXX) $(CFLAGS) $(INC_FLAGS) -c $< -o $@ | |
| all: $(BIN) | |
| @rm *.o | |
| @echo "Done" | |
| $(BIN): $(OBJS) | |
| @echo "Compiling REVOStorage" | |
| @$(CXX) $(OBJS) $(LIBS) $(CFLAGS) -o $(BIN) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <cstring> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <arpa/inet.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <string.h> | |
| #include <sys/types.h> | |
| #include <time.h> | |
| #include "libGetDVStream.h" | |
| #include "libDVStream.h" | |
| #include "i2c_eeprom.h" | |
| #define MSG_TYPE MSG_DV_TYPE_MSG3 /*!< Mensage type (one per user) */ | |
| #define VIDEO_CHANNEL 0 | |
| unsigned int VIDEO_INDEX = 2; | |
| int getConnfd() | |
| { | |
| int listenfd = 0, connfd = 0; | |
| struct sockaddr_in serv_addr; | |
| listenfd = socket(AF_INET, SOCK_STREAM, 0); | |
| memset(&serv_addr, '0', sizeof(serv_addr)); | |
| serv_addr.sin_family = AF_INET; | |
| serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); | |
| serv_addr.sin_port = htons(5000); | |
| bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); | |
| listen(listenfd, 10); | |
| return accept(listenfd, (struct sockaddr*)NULL, NULL); | |
| } | |
| int main(int argc, char* argv[]){ | |
| int connfd = getConnfd(); | |
| // Syncronous get stream | |
| GetDVStreamInit(MSG_TYPE, NULL, NULL); | |
| int ret; | |
| int old_ret = 0; | |
| unsigned int oldSerial; | |
| GET_PARAM mGetDataParam; | |
| // Loop stream | |
| while (1) { | |
| // Get the data stream | |
| ret = DVStreamGetDVData1(MSG_TYPE, VIDEO_INDEX,&mGetDataParam,0, VIDEO_CHANNEL); | |
| // Check valid data stream | |
| if (ret > 0){ | |
| if (ret != old_ret) { | |
| if (ret == 1) printf("NO FRAME DATA\n"); | |
| else if(ret == 2) printf("NO SERVER CONECTION\n"); | |
| else if(ret == 3) printf("PAUSED STREAM\n"); | |
| else printf("UNKOWN RETURN\n"); | |
| } | |
| // printf("Return = %d | Serial Number = %d\n", ret, mGetDataParam.SerialNumber); | |
| old_ret = ret; | |
| continue; | |
| } | |
| // Check internal erro | |
| else if (ret < 0){ | |
| printf("STREAM LIB ERROR: %d\n", ret); | |
| break; | |
| } | |
| // Valid stream data | |
| if(mGetDataParam.DataPtr != NULL && mGetDataParam.len > 0){ | |
| // Notify if a discontinuos frame is detect | |
| if (mGetDataParam.SerialNumber > oldSerial+1 && oldSerial != 0){ | |
| printf("ERROR ON SERIAL FRAME %d(last) -> %d(new)\n", oldSerial, mGetDataParam.SerialNumber); | |
| //break; | |
| } | |
| oldSerial = mGetDataParam.SerialNumber; | |
| printf("GET FRAME: TYPE %d | NUM %d | LEN %d\n", mGetDataParam.FrameType, mGetDataParam.SerialNumber, mGetDataParam.len); | |
| // Store the stream | |
| //store->storeData((uint8_t *)mGetDataParam.DataPtr, mGetDataParam.len, mGetDataParam.FrameType == 1); | |
| write(connfd, (uint8_t *)&mGetDataParam.len, sizeof(mGetDataParam.len)); | |
| write(connfd, (uint8_t *)mGetDataParam.DataPtr, mGetDataParam.len); | |
| } | |
| old_ret = ret; | |
| } | |
| DVStreamGetDVDataStop(MSG_TYPE, 1); | |
| GetDVStreamCleanup(); | |
| printf("End of execution\n"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment