'먹거리' 카테고리의 다른 글
[성수/성수역/성수카페거리] 색다른면 (0) | 2018.06.28 |
---|---|
[화양동] 우화등선 (0) | 2018.06.27 |
[성수] 사진창고 (0) | 2018.02.09 |
[성수역] 메콩타이 (0) | 2018.02.07 |
[성수/성수동/성수이마트] 분식집이다 (0) | 2018.02.06 |
[성수/성수역/성수카페거리] 색다른면 (0) | 2018.06.28 |
---|---|
[화양동] 우화등선 (0) | 2018.06.27 |
[성수] 사진창고 (0) | 2018.02.09 |
[성수역] 메콩타이 (0) | 2018.02.07 |
[성수/성수동/성수이마트] 분식집이다 (0) | 2018.02.06 |
player.cpp(57): error C4996: 'av_register_all': deprecated로 선언되었습니다.
include\libavformat\avformat.h(2025) : 'av_register_all' 선언을 참조하십시오.
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <stdio.h>
// compatibility with newer API
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
#define av_frame_alloc avcodec_alloc_frame
#define av_frame_free avcodec_free_frame
#endif
void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
FILE *pFile;
char szFilename[32];
int y;
// Open file
sprintf_s(szFilename, "frame%d.ppm", iFrame);
fopen_s(&pFile, szFilename, "wb");
if (pFile == NULL)
return;
// Write header
fprintf(pFile, "P6\n%d %d\n255\n", width, height);
// Write pixel data
for (y = 0; y<height; y++)
fwrite(pFrame->data[0] + y*pFrame->linesize[0], 1, width * 3, pFile);
// Close file
fclose(pFile);
}
int main(int argc, char *argv[]) {
// Initalizing these to NULL prevents segfaults!
AVFormatContext *pFormatCtx = NULL;
int i, videoStream;
AVCodecContext *pCodecCtxOrig = NULL;
AVCodecContext *pCodecCtx = NULL;
AVCodec *pCodec = NULL;
AVFrame *pFrame = NULL;
AVFrame *pFrameRGB = NULL;
AVPacket packet;
int frameFinished;
int numBytes;
uint8_t *buffer = NULL;
struct SwsContext *sws_ctx = NULL;
if (argc < 2) {
printf("Please provide a movie file\n");
return -1;
}
// Register all formats and codecs
av_register_all();
// Open video file
if (avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) != 0)
return -1; // Couldn't open file
// Retrieve stream information
if (avformat_find_stream_info(pFormatCtx, NULL)<0)
return -1; // Couldn't find stream information
// Dump information about file onto standard error
av_dump_format(pFormatCtx, 0, argv[1], 0);
// Find the first video stream
videoStream = -1;
for (i = 0; i<pFormatCtx->nb_streams; i++)
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
videoStream = i;
break;
}
if (videoStream == -1)
return -1; // Didn't find a video stream
// Get a pointer to the codec context for the video stream
pCodecCtxOrig = pFormatCtx->streams[videoStream]->codec;
// Find the decoder for the video stream
pCodec = avcodec_find_decoder(pCodecCtxOrig->codec_id);
if (pCodec == NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}
// Copy context
pCodecCtx = avcodec_alloc_context3(pCodec);
if (avcodec_copy_context(pCodecCtx, pCodecCtxOrig) != 0) {
fprintf(stderr, "Couldn't copy codec context");
return -1; // Error copying codec context
}
// Open codec
if (avcodec_open2(pCodecCtx, pCodec, NULL)<0)
return -1; // Could not open codec
// Allocate video frame
pFrame = av_frame_alloc();
// Allocate an AVFrame structure
pFrameRGB = av_frame_alloc();
if (pFrameRGB == NULL)
return -1;
// Determine required buffer size and allocate buffer
numBytes = avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
pCodecCtx->height);
buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
// Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture
avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
pCodecCtx->width, pCodecCtx->height);
// initialize SWS context for software scaling
sws_ctx = sws_getContext(pCodecCtx->width,
pCodecCtx->height,
pCodecCtx->pix_fmt,
pCodecCtx->width,
pCodecCtx->height,
PIX_FMT_RGB24,
SWS_BILINEAR,
NULL,
NULL,
NULL
);
// Read frames and save first five frames to disk
i = 0;
while (av_read_frame(pFormatCtx, &packet) >= 0) {
// Is this a packet from the video stream?
if (packet.stream_index == videoStream) {
// Decode video frame
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
// Did we get a video frame?
if (frameFinished) {
// Convert the image from its native format to RGB
sws_scale(sws_ctx, (uint8_t const * const *)pFrame->data,
pFrame->linesize, 0, pCodecCtx->height,
pFrameRGB->data, pFrameRGB->linesize);
// Save the frame to disk
if (++i <= 5)
SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,
i);
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}
// Free the RGB image
av_free(buffer);
av_frame_free(&pFrameRGB);
// Free the YUV frame
av_frame_free(&pFrame);
// Close the codecs
avcodec_close(pCodecCtx);
avcodec_close(pCodecCtxOrig);
// Close the video file
avformat_close_input(&pFormatCtx);
return 0;
}
Solution
https://github.com/intel/libyami-utils/commit/124712bfd4cccd43ab60bd160b0f8990d20e5911
[CPP] NTP Sync LocalClockOffset (0) | 2019.12.23 |
---|---|
ActiveX 웹배포 (0) | 2019.12.10 |
중복 실행 방지 코드 (Mutex) (0) | 2018.04.18 |
WAVE form wFormatTag IDs (0) | 2018.04.04 |
CString Tokenize (0) | 2017.10.19 |
중복 실행 방지 코드 (Mutex)
Creates or opens a named or unnamed mutex object.
To specify an access mask for the object, use the CreateMutexEx function.
HANDLE WINAPI CreateMutex( _In_opt_ LPSECURITY_ATTRIBUTES lpMutexAttributes, _In_ BOOL bInitialOwner, _In_opt_ LPCTSTR lpName );
A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the handle cannot be inherited by child processes.
The lpSecurityDescriptor member of the structure specifies a security descriptor for the new mutex. If lpMutexAttributes is NULL, the mutex gets a default security descriptor. The ACLs in the default security descriptor for a mutex come from the primary or impersonation token of the creator. For more information, see Synchronization Object Security and Access Rights.
If this value is TRUE and the caller created the mutex, the calling thread obtains initial ownership of the mutex object. Otherwise, the calling thread does not obtain ownership of the mutex. To determine if the caller created the mutex, see the Return Values section.
The name of the mutex object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If lpName matches the name of an existing named mutex object, this function requests the MUTEX_ALL_ACCESSaccess right. In this case, the bInitialOwner parameter is ignored because it has already been set by the creating process. If the lpMutexAttributes parameter is not NULL, it determines whether the handle can be inherited, but its security-descriptor member is ignored.
If lpName is NULL, the mutex object is created without a name.
If lpName matches the name of an existing event, semaphore, waitable timer, job, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same namespace.
The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session namespace. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces. Fast user switching is implemented using Terminal Services sessions. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.
The object can be created in a private namespace. For more information, see Object Namespaces.
#include <windows.h> #include <stdio.h> #define THREADCOUNT 2 HANDLE ghMutex; DWORD WINAPI WriteToDatabase( LPVOID ); int main( void ) { HANDLE aThread[THREADCOUNT]; DWORD ThreadID; int i; // Create a mutex with no initial owner ghMutex = CreateMutex( NULL, // default security attributes FALSE, // initially not owned NULL); // unnamed mutex if (ghMutex == NULL) { printf("CreateMutex error: %d\n", GetLastError()); return 1; } // Create worker threads for( i=0; i < THREADCOUNT; i++ ) { aThread[i] = CreateThread( NULL, // default security attributes 0, // default stack size (LPTHREAD_START_ROUTINE) WriteToDatabase, NULL, // no thread function arguments 0, // default creation flags &ThreadID); // receive thread identifier if( aThread[i] == NULL ) { printf("CreateThread error: %d\n", GetLastError()); return 1; } } // Wait for all threads to terminate WaitForMultipleObjects(THREADCOUNT, aThread, TRUE, INFINITE); // Close thread and mutex handles for( i=0; i < THREADCOUNT; i++ ) CloseHandle(aThread[i]); CloseHandle(ghMutex); return 0; } DWORD WINAPI WriteToDatabase( LPVOID lpParam ) { // lpParam not used in this example UNREFERENCED_PARAMETER(lpParam); DWORD dwCount=0, dwWaitResult; // Request ownership of mutex. while( dwCount < 20 ) { dwWaitResult = WaitForSingleObject( ghMutex, // handle to mutex INFINITE); // no time-out interval switch (dwWaitResult) { // The thread got ownership of the mutex case WAIT_OBJECT_0: __try { // TODO: Write to the database printf("Thread %d writing to database...\n", GetCurrentThreadId()); dwCount++; } __finally { // Release ownership of the mutex object if (! ReleaseMutex(ghMutex)) { // Handle error. } } break; // The thread got ownership of an abandoned mutex // The database is in an indeterminate state case WAIT_ABANDONED: return FALSE; } } return TRUE; }
ActiveX 웹배포 (0) | 2019.12.10 |
---|---|
ffmpeg sample (0) | 2018.06.20 |
WAVE form wFormatTag IDs (0) | 2018.04.04 |
CString Tokenize (0) | 2017.10.19 |
[CPP] Windows Service 간단하게 만들기 (0) | 2017.10.17 |
/* WAVE form wFormatTag IDs */
#define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
#define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */
#define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */
#define WAVE_FORMAT_VSELP 0x0004 /* Compaq Computer Corp. */
#define WAVE_FORMAT_IBM_CVSD 0x0005 /* IBM Corporation */
#define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */
#define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */
#define WAVE_FORMAT_DTS 0x0008 /* Microsoft Corporation */
#define WAVE_FORMAT_DRM 0x0009 /* Microsoft Corporation */
#define WAVE_FORMAT_WMAVOICE9 0x000A /* Microsoft Corporation */
#define WAVE_FORMAT_WMAVOICE10 0x000B /* Microsoft Corporation */
#define WAVE_FORMAT_OKI_ADPCM 0x0010 /* OKI */
#define WAVE_FORMAT_DVI_ADPCM 0x0011 /* Intel Corporation */
#define WAVE_FORMAT_IMA_ADPCM (WAVE_FORMAT_DVI_ADPCM) /* Intel Corporation */
#define WAVE_FORMAT_MEDIASPACE_ADPCM 0x0012 /* Videologic */
#define WAVE_FORMAT_SIERRA_ADPCM 0x0013 /* Sierra Semiconductor Corp */
#define WAVE_FORMAT_G723_ADPCM 0x0014 /* Antex Electronics Corporation */
#define WAVE_FORMAT_DIGISTD 0x0015 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIGIFIX 0x0016 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIALOGIC_OKI_ADPCM 0x0017 /* Dialogic Corporation */
#define WAVE_FORMAT_MEDIAVISION_ADPCM 0x0018 /* Media Vision, Inc. */
#define WAVE_FORMAT_CU_CODEC 0x0019 /* Hewlett-Packard Company */
#define WAVE_FORMAT_YAMAHA_ADPCM 0x0020 /* Yamaha Corporation of America */
#define WAVE_FORMAT_SONARC 0x0021 /* Speech Compression */
#define WAVE_FORMAT_DSPGROUP_TRUESPEECH 0x0022 /* DSP Group, Inc */
#define WAVE_FORMAT_ECHOSC1 0x0023 /* Echo Speech Corporation */
#define WAVE_FORMAT_AUDIOFILE_AF36 0x0024 /* Virtual Music, Inc. */
#define WAVE_FORMAT_APTX 0x0025 /* Audio Processing Technology */
#define WAVE_FORMAT_AUDIOFILE_AF10 0x0026 /* Virtual Music, Inc. */
#define WAVE_FORMAT_PROSODY_1612 0x0027 /* Aculab plc */
#define WAVE_FORMAT_LRC 0x0028 /* Merging Technologies S.A. */
#define WAVE_FORMAT_DOLBY_AC2 0x0030 /* Dolby Laboratories */
#define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */
#define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */
#define WAVE_FORMAT_ANTEX_ADPCME 0x0033 /* Antex Electronics Corporation */
#define WAVE_FORMAT_CONTROL_RES_VQLPC 0x0034 /* Control Resources Limited */
#define WAVE_FORMAT_DIGIREAL 0x0035 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIGIADPCM 0x0036 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_CONTROL_RES_CR10 0x0037 /* Control Resources Limited */
#define WAVE_FORMAT_NMS_VBXADPCM 0x0038 /* Natural MicroSystems */
#define WAVE_FORMAT_CS_IMAADPCM 0x0039 /* Crystal Semiconductor IMA ADPCM */
#define WAVE_FORMAT_ECHOSC3 0x003A /* Echo Speech Corporation */
#define WAVE_FORMAT_ROCKWELL_ADPCM 0x003B /* Rockwell International */
#define WAVE_FORMAT_ROCKWELL_DIGITALK 0x003C /* Rockwell International */
#define WAVE_FORMAT_XEBEC 0x003D /* Xebec Multimedia Solutions Limited */
#define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */
#define WAVE_FORMAT_G728_CELP 0x0041 /* Antex Electronics Corporation */
#define WAVE_FORMAT_MSG723 0x0042 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
#define WAVE_FORMAT_RT24 0x0052 /* InSoft, Inc. */
#define WAVE_FORMAT_PAC 0x0053 /* InSoft, Inc. */
#define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
#define WAVE_FORMAT_LUCENT_G723 0x0059 /* Lucent Technologies */
#define WAVE_FORMAT_CIRRUS 0x0060 /* Cirrus Logic */
#define WAVE_FORMAT_ESPCM 0x0061 /* ESS Technology */
#define WAVE_FORMAT_VOXWARE 0x0062 /* Voxware Inc */
#define WAVE_FORMAT_CANOPUS_ATRAC 0x0063 /* Canopus, co., Ltd. */
#define WAVE_FORMAT_G726_ADPCM 0x0064 /* APICOM */
#define WAVE_FORMAT_G722_ADPCM 0x0065 /* APICOM */
#define WAVE_FORMAT_DSAT_DISPLAY 0x0067 /* Microsoft Corporation */
#define WAVE_FORMAT_VOXWARE_BYTE_ALIGNED 0x0069 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_AC8 0x0070 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_AC10 0x0071 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_AC16 0x0072 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_AC20 0x0073 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_RT24 0x0074 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_RT29 0x0075 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_RT29HW 0x0076 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_VR12 0x0077 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_VR18 0x0078 /* Voxware Inc */
#define WAVE_FORMAT_VOXWARE_TQ40 0x0079 /* Voxware Inc */
#define WAVE_FORMAT_SOFTSOUND 0x0080 /* Softsound, Ltd. */
#define WAVE_FORMAT_VOXWARE_TQ60 0x0081 /* Voxware Inc */
#define WAVE_FORMAT_MSRT24 0x0082 /* Microsoft Corporation */
#define WAVE_FORMAT_G729A 0x0083 /* AT&T Labs, Inc. */
#define WAVE_FORMAT_MVI_MVI2 0x0084 /* Motion Pixels */
#define WAVE_FORMAT_DF_G726 0x0085 /* DataFusion Systems (Pty) (Ltd) */
#define WAVE_FORMAT_DF_GSM610 0x0086 /* DataFusion Systems (Pty) (Ltd) */
#define WAVE_FORMAT_ISIAUDIO 0x0088 /* Iterated Systems, Inc. */
#define WAVE_FORMAT_ONLIVE 0x0089 /* OnLive! Technologies, Inc. */
#define WAVE_FORMAT_SBC24 0x0091 /* Siemens Business Communications Sys */
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
#define WAVE_FORMAT_MEDIASONIC_G723 0x0093 /* MediaSonic */
#define WAVE_FORMAT_PROSODY_8KBPS 0x0094 /* Aculab plc */
#define WAVE_FORMAT_ZYXEL_ADPCM 0x0097 /* ZyXEL Communications, Inc. */
#define WAVE_FORMAT_PHILIPS_LPCBB 0x0098 /* Philips Speech Processing */
#define WAVE_FORMAT_PACKED 0x0099 /* Studer Professional Audio AG */
#define WAVE_FORMAT_MALDEN_PHONYTALK 0x00A0 /* Malden Electronics Ltd. */
#define WAVE_FORMAT_RAW_AAC1 0x00FF /* For Raw AAC, with format block AudioSpecificConfig() (as defined by MPEG-4), that follows WAVEFORMATEX */
#define WAVE_FORMAT_RHETOREX_ADPCM 0x0100 /* Rhetorex Inc. */
#define WAVE_FORMAT_IRAT 0x0101 /* BeCubed Software Inc. */
#define WAVE_FORMAT_VIVO_G723 0x0111 /* Vivo Software */
#define WAVE_FORMAT_VIVO_SIREN 0x0112 /* Vivo Software */
#define WAVE_FORMAT_DIGITAL_G723 0x0123 /* Digital Equipment Corporation */
#define WAVE_FORMAT_SANYO_LD_ADPCM 0x0125 /* Sanyo Electric Co., Ltd. */
#define WAVE_FORMAT_SIPROLAB_ACEPLNET 0x0130 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_SIPROLAB_ACELP4800 0x0131 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_SIPROLAB_ACELP8V3 0x0132 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_SIPROLAB_G729 0x0133 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_SIPROLAB_G729A 0x0134 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_SIPROLAB_KELVIN 0x0135 /* Sipro Lab Telecom Inc. */
#define WAVE_FORMAT_G726ADPCM 0x0140 /* Dictaphone Corporation */
#define WAVE_FORMAT_QUALCOMM_PUREVOICE 0x0150 /* Qualcomm, Inc. */
#define WAVE_FORMAT_QUALCOMM_HALFRATE 0x0151 /* Qualcomm, Inc. */
#define WAVE_FORMAT_TUBGSM 0x0155 /* Ring Zero Systems, Inc. */
#define WAVE_FORMAT_MSAUDIO1 0x0160 /* Microsoft Corporation */
#define WAVE_FORMAT_WMAUDIO2 0x0161 /* Microsoft Corporation */
#define WAVE_FORMAT_WMAUDIO3 0x0162 /* Microsoft Corporation */
#define WAVE_FORMAT_WMAUDIO_LOSSLESS 0x0163 /* Microsoft Corporation */
#define WAVE_FORMAT_WMASPDIF 0x0164 /* Microsoft Corporation */
#define WAVE_FORMAT_UNISYS_NAP_ADPCM 0x0170 /* Unisys Corp. */
#define WAVE_FORMAT_UNISYS_NAP_ULAW 0x0171 /* Unisys Corp. */
#define WAVE_FORMAT_UNISYS_NAP_ALAW 0x0172 /* Unisys Corp. */
#define WAVE_FORMAT_UNISYS_NAP_16K 0x0173 /* Unisys Corp. */
#define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH8 0x0202 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH10 0x0203 /* Creative Labs, Inc */
#define WAVE_FORMAT_UHER_ADPCM 0x0210 /* UHER informatic GmbH */
#define WAVE_FORMAT_QUARTERDECK 0x0220 /* Quarterdeck Corporation */
#define WAVE_FORMAT_ILINK_VC 0x0230 /* I-link Worldwide */
#define WAVE_FORMAT_RAW_SPORT 0x0240 /* Aureal Semiconductor */
#define WAVE_FORMAT_ESST_AC3 0x0241 /* ESS Technology, Inc. */
#define WAVE_FORMAT_GENERIC_PASSTHRU 0x0249
#define WAVE_FORMAT_IPI_HSX 0x0250 /* Interactive Products, Inc. */
#define WAVE_FORMAT_IPI_RPELP 0x0251 /* Interactive Products, Inc. */
#define WAVE_FORMAT_CS2 0x0260 /* Consistent Software */
#define WAVE_FORMAT_SONY_SCX 0x0270 /* Sony Corp. */
#define WAVE_FORMAT_FM_TOWNS_SND 0x0300 /* Fujitsu Corp. */
#define WAVE_FORMAT_BTV_DIGITAL 0x0400 /* Brooktree Corporation */
#define WAVE_FORMAT_QDESIGN_MUSIC 0x0450 /* QDesign Corporation */
#define WAVE_FORMAT_VME_VMPCM 0x0680 /* AT&T Labs, Inc. */
#define WAVE_FORMAT_TPC 0x0681 /* AT&T Labs, Inc. */
#define WAVE_FORMAT_OLIGSM 0x1000 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLIADPCM 0x1001 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLICELP 0x1002 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLISBC 0x1003 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLIOPR 0x1004 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_LH_CODEC 0x1100 /* Lernout & Hauspie */
#define WAVE_FORMAT_NORRIS 0x1400 /* Norris Communications, Inc. */
#define WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS 0x1500 /* AT&T Labs, Inc. */
#define WAVE_FORMAT_MPEG_ADTS_AAC 0x1600 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEG_RAW_AAC 0x1601 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEG_LOAS 0x1602 /* Microsoft Corporation (MPEG-4 Audio Transport Streams (LOAS/LATM) */
#define WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC 0x1608 /* Microsoft Corporation */
#define WAVE_FORMAT_NOKIA_MPEG_RAW_AAC 0x1609 /* Microsoft Corporation */
#define WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC 0x160A /* Microsoft Corporation */
#define WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC 0x160B /* Microsoft Corporation */
#define WAVE_FORMAT_MPEG_HEAAC 0x1610 /* Microsoft Corporation (MPEG-2 AAC or MPEG-4 HE-AAC v1/v2 streams with any payload (ADTS, ADIF, LOAS/LATM, RAW). Format block includes MP4 AudioSpecificConfig() -- see HEAACWAVEFORMAT below */
#define WAVE_FORMAT_DVM 0x2000 /* FAST Multimedia AG */
#define WAVE_FORMAT_DTS2 0x2001
ffmpeg sample (0) | 2018.06.20 |
---|---|
중복 실행 방지 코드 (Mutex) (0) | 2018.04.18 |
CString Tokenize (0) | 2017.10.19 |
[CPP] Windows Service 간단하게 만들기 (0) | 2017.10.17 |
WaitForMultipleObjects (0) | 2017.04.19 |
Android Camera 권한
Android M 이후 버전에서는
팝업으로 사용자에게 권한을 받아한다.
/**********권한 요청************/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
/**
* 사용자 단말기의 권한 중 "카메라" 권한이 허용되어 있는지 확인한다.
* Android는 C언어 기반으로 만들어졌기 때문에 Boolean 타입보다 Int 타입을 사용한다.
*/
int permissionResult = checkSelfPermission(Manifest.permission.CAMERA);
/** * 패키지는 안드로이드 어플리케이션의 아이디이다. *
* 현재 어플리케이션이 카메라에 대해 거부되어있는지 확인한다. */
if (permissionResult == PackageManager.PERMISSION_DENIED) {
/** * 사용자가 CALL_PHONE 권한을 거부한 적이 있는지 확인한다. *
* 거부한적이 있으면 True를 리턴하고 *
* 거부한적이 없으면 False를 리턴한다. */
if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("권한이 필요합니다.").setMessage("이 기능을 사용하기 위해서는 단말기의 \"카메라\" 권한이 필요합니다. 계속 하시겠습니까?")
.setPositiveButton("네", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/** * 새로운 인스턴스(onClickListener)를 생성했기 때문에 *
* 버전체크를 다시 해준다. */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// CALL_PHONE 권한을 Android OS에 요청한다.
requestPermissions(new String[]{Manifest.permission.CAMERA}, 1000);
}
}
})
.setNegativeButton("아니요", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "기능을 취소했습니다", Toast.LENGTH_SHORT).show();
}
}).create().show();
return -1;
// need to retry
}
// 최초로 권한을 요청할 때
else {
// CALL_PHONE 권한을 Android OS에 요청한다.
requestPermissions(new String[]{Manifest.permission.CAMERA}, 1000);
}
}
// CALL_PHONE의 권한이 있을 때
else {
}
}
/************권한요청 끝**************/
Android SignalR Sample (0) | 2016.06.25 |
---|---|
Android 위치 추적, 기록 (0) | 2016.04.11 |
Software with the most vulnerabilities in 2015 (2) | 2016.01.10 |
Android , OpenCV 연동하여 카메라 촬영시 해상도 문제 (0) | 2015.12.19 |
Opencv 안드로이드 연동 중 Resolution 설정 문제시 (0) | 2015.12.19 |
JNA Error
int hr = m_pObjectKey.CreateInstance(__uuidof(KeyObject));
해당 구문에서
CreateInstance 의 리턴 값이
%x : 80040154
%d : -2147221164
형태로 계속 리턴되는 경우
System.Runtime.InteropServices.COMExcetption : 80040154 오류로 인해 CLSID가 {100202C1-E260-11CF-AE68-00AA004A34D5}인 구성 요소의 COM 클래스 팩터리를 검색하지 못했습니다.
쉽게 말하면 해당 라이브러리의 DLL 파일의 경로를 찾을수 없어서
객체를 만들 수 없다는 이야기이다.
1) regasm, regsrv 를 이용하여 재등록을 시도해 보고,
그래도 안된다면
2) regasm 의 경우 /codebase 옵션을 사용 해 보라
window.open('xxxx.html', 'modal') close (0) | 2019.03.06 |
---|---|
Java notepad.exe Runtime.getRuntime().exec ProcessBuilder 로 실행하기 (0) | 2017.03.02 |
Java CreateProcess Error=2 AccessControlException (0) | 2017.02.28 |
Java Applet 설정 (0) | 2017.02.28 |
Java SocketServer control Image, DBConnect, String (1) | 2016.10.28 |
C# 에서 C++ DLL 불러서 쓰기 #5
5. error CS0214: 포인터와 고정 크기 버퍼는 안전하지 않은 컨텍스트에서만 사용할 수 있습니다.
포인터와 고정 크기 버퍼는 안전하지 않은 컨텍스트에서만 사용할 수 있습니다.
포인터는 안전하지 않은 키워드에만 사용할 수 있습니다. 자세한 내용은 안전하지 않은 코드 및 포인터를 참조하세요.
다음 샘플에서는 CS0214를 생성합니다.
// CS0214.cs
// compile with: /target:library /unsafe
public struct S
{
public int a;
}
public class MyClass
{
public static void Test()
{
S s = new S();
S * s2 = &s; // CS0214
s2->a = 3; // CS0214
s.a = 0;
}
// OK
unsafe public static void Test2()
{
S s = new S();
S * s2 = &s;
s2->a = 3;
s.a = 0;
}
}
C# Panel DirectShow Video ScrollBar (0) | 2018.10.22 |
---|---|
참조 dll 강력키 생성 방법 (0) | 2018.09.10 |
C# 에서 C++ DLL 불러서 쓰기 #4 (0) | 2018.02.14 |
C# 에서 C++ DLL 불러서 쓰기 [도움되는 링크들] (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #2 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #4
4. 멤버 함수 가져오기
C++
#ifdef BOX_EXPORTS
#define BOX_API __declspec(dllexport)
#else
#define BOX_API __declspec(dllimport)
#endif
Class BOX_API Box{
public:
Box();
int setInt(int a);
void setString(char* str);
}
int setInt(int a);
void setString(char* str);
이 멤버 함수들을 가져와서 사용하고 싶다.
참고 : http://tansanc.tistory.com/526?category=772232 [TanSanC]
아래와 같이 사용하고 싶지만
불가능하다
namespace BoxConsoleApplication
{
class Program
{
[DllImport("Box.dll", CallingConvention = CallingConvention.Cdecl)]
static public extern IntPtr CreateCBox();
[DllImport("Box.dll", CallingConvention = CallingConvention.Cdecl)]
static public extern void DisposeCBox(IntPtr pTestClassObject);
unsafe static void Main(string[] args)
{
IntPtr pCBoxClass = CreateCBox(); ;
pCBoxClass.setInt(3);
pCBoxClass.setString("HelloWorld");
DisposeCBox(pCBoxClass );
pCBoxClass = IntPtr.Zero;
}
}
}
pCBoxClass.setInt(3);
pCBoxClass.setString("HelloWorld");
클래스 내부 멤버 변수라 바로 가져올 수는 없다.
사용 할 수 있는 방법은
클래스 생성시와 같이
extern 으로 접근가능 하도록 만들어 주어야 한다.
기본 형태
C++
.h
extern "C" BOX_API int setInt(CBox* pObject, int a);
.cpp
extern "C" BOX_API int setInt(CBox* pObject, int a)
{
if (pObject != NULL)
{
pObject->setInt(a);
}
return -1;
}
이렇게 C++ DLL 내부에서
클래스 객체에 접근하여
객체의 멤버 함수를 호출하여 준다.
void setString(char* str);
참조 dll 강력키 생성 방법 (0) | 2018.09.10 |
---|---|
C# 에서 C++ DLL 불러서 쓰기 #5 (0) | 2018.02.15 |
C# 에서 C++ DLL 불러서 쓰기 [도움되는 링크들] (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #2 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #3 (0) | 2018.02.13 |
http://freeprog.tistory.com/220
https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/unsafe
http://heroeskdw.tistory.com/entry/C-MFC-DLL%EC%9D%84-C%EC%97%90%EC%84%9C-%EB%A1%9C%EB%94%A9%ED%95%98%EA%B8%B0
https://www.codeproject.com/Articles/18032/How-to-Marshal-a-C-Class
http://www.sysnet.pe.kr/2/0/11132
http://www.sysnet.pe.kr/2/0/11111
https://msdn.microsoft.com/ko-kr/library/62688esh.aspx
https://social.msdn.microsoft.com/Forums/en-US/b85fc9dd-acc5-42dc-a28e-b70953bf1170/unhandled-exception-systemruntimeinteropservicessehexception-additional-information-external?forum=vcgeneral
https://msdn.microsoft.com/ko-kr/library/system.io.filestream.read(v=vs.110).aspx
http://storycompiler.tistory.com/214
C# 에서 C++ DLL 불러서 쓰기 #5 (0) | 2018.02.15 |
---|---|
C# 에서 C++ DLL 불러서 쓰기 #4 (0) | 2018.02.14 |
C# 에서 C++ DLL 불러서 쓰기 #2 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #3 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #1 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #2
2. DLL 참조하기
C++ DLL 을 C# 에서 사용하려면
일단 참조를 하여야 한다.
참조를 하는 방법은
Visual Studio 2013 버전에서는
[솔루션 탐색기] -> [솔루션] 하위 -> [프로젝트] 하위 -> [참조] -> 우클릭 -> [참조 추가] -> 우측 하단 [찾아보기(B)...] -> 원하는 DLL 찾아서 선택
선택을 하면 [참조] 하단에 참조된 DLL 이 보이게 된다.
여기서.......
이 글은
참조된 DLL 을 더블클릭하여 [개체 브라우저]로 보았을때도
하위 멤버들이 보이지 않는
C++ DLL 일 경우 해결하는 방법들을
순서...에 상관없이
메모해 두려고 한다.
C# 에서 C++ DLL 불러서 쓰기 #4 (0) | 2018.02.14 |
---|---|
C# 에서 C++ DLL 불러서 쓰기 [도움되는 링크들] (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #3 (0) | 2018.02.13 |
C# 에서 C++ DLL 불러서 쓰기 #1 (0) | 2018.02.13 |
C# 프로그램 소스코드 경과시간 측정 (0) | 2017.12.28 |